Reputation: 16920
I created a simple Applet using JApplet and everything seems to work fine but as soon i create an object of my userdefined class named ChatUser in my applet, i get this error :-
SEVERE: java.lang.ClassNotFoundException: applet.ChatUser
at com.sun.enterprise.loader.ASURLClassLoader.findClassData(ASURLClassLoader.java:713)
at com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader.java:626)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:604)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at misc.ChatClient.run(ChatClient.java:43)
Any idea what can be wrong? It only happens when i create an object of any user defined class. Do i need to set some security settings or something? Please help :(
Upvotes: 0
Views: 1537
Reputation: 1333
It looks like a classpath problem the way you're starting the applet.
If you start the applet using NetBeans Run file, Netbeans probably takes your project classpath as classpath for the Applet and not what you've specified in the HTML page of the Applet. As you can see the classloader is com.sun.enterprise.loader.ASURLClassLoader which is not the standard classloader (URLClassLoader) that Applets use. Run your applet using the browser or the appletviewer or jnlp (Java webstart).
Upvotes: 0
Reputation: 1109635
It just means that the mentioned class is missing in the runtime classpath of the applet.
You do realize that applets runs at a completely different environment than where the webserver runs, namely the client machine? The client would need to download the needed libraries first. That class should be included in the applet's main JAR file or in any of the libraries referenced in the applet's archive
parameter. You can specify multiple JAR's commaseparated.
<param name="archive" value="applet.jar,library1.jar,library2.jar">
This instructs the client which JAR's to download before running the applet.
Upvotes: 1