Hi guys, I've done some testing and my basic code is working. By using a test class I am able to connect to a servlet, get records from a database and print them in the test program. Check this post. By using the same base classes I am trying to get the DB records into an Applet. The previous test is working fine but now when I try to get data into the Applet I get an error message and a blank applet. I�ve been using NetBeans 6.1 IDE.
I think that my web app structure is the problem. Please notice that after every compilation I drag and drop mainApplet.class from web/WEB-INF/classess/ folder to the web folder root. The best option would be to place mainApplet.class in class/all/ subfolder together with all other classes, but I don�t know how to call it from the jsp page (<APPLET CODE=�mainApplet.class�). I�ve tried CODE=�all.mainApplet.class� but it doesn�t work.
NETBEANS WEB FOLDER STRUCTURE: Index.jsp // JSP wrapper page mainApplet.class//Applet class WEB-INF/classess/all/Course.class//Course object class /all/GetCluster.class//Servlet class
EROR MESSAGE: bobo: java.lang.ClassNotFoundException: all.Course java.lang.ClassNotFoundException: all.Course at sun.applet.AppletClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.applet.AppletClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at java.io.ObjectInputStream.resolveClass(Unknown Source) at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source) at java.io.ObjectInputStream.readClassDesc(Unknown Source) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readArray(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.defaultReadFields(Unknown Source) at java.io.ObjectInputStream.readSerialData(Unknown Source) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at mainApplet.getRecords(mainApplet.java:350) at mainApplet.createNodes(mainApplet.java:150) at mainApplet.buildGraph(mainApplet.java:295) at mainApplet.init(mainApplet.java:115) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source)
JSP PAGE CODE:
Here is the Applet code causing the error. The same two methods I've used in the testing class without a problem.
Thanks Ulf, I've moved all classes on the root level where jsp page is located and it works now. On Monday I'll keep working on it. Have a nice weekend.
Kind Regards, Bill
Joined: Mar 22, 2005
By the way what does "I�ve tried CODE=�all.mainApplet.class� but it doesn�t work" mean? You're right that you should put classes in packages, and generally that works fine. You could try "code=all.mainApplet" instead of "code=all.mainApplet.class".