-
Applet throw ClassNotFound exception when one of the file is recompiled
Hi all:
I am working on a web application that somebody else has worked on in the past. There is a need to modify a java file recompile it and replace with the one inside a signed jar file. Btw, the jar file is in one of the tomcat 5's application directory.
What I did was :
extract the jar file.
recompiled the source code (only one .java file has be recompiled, the rest of them are kept as class files).
replace the recompiled class file with the old class file.
jar'd everything together using command "jar -cMf myJar.jar folder1 folder2 folder3 file1.class file2.class"
reason why I used "M" is because I don't want to recreate a Manifest folder and I kept the old "SF" inside the META-INF folder as well.
I reloaded the application, and when I ran it, it gave me "ClassNotFound" exception, stating it couldn't find the new class file I just compiled.
at sun.plugin2.applet.Applet2ClassLoader.findClass(Un known Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(U nknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unk nown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unk nown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionR unnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.lang.ClassNotFoundException: IORLFCallApplet.class
BTW, I compiled the java file in my local machine, which does not have the same version jdk as the one in the server. My is 1.6.0_24 and the server has 1.6.0_14. So I highly doubted it is the problem. Thanks.
-
Re: Applet throw ClassNotFound exception when one of the file is recompiled
Use a zip file utility to look inside of the jar file and see if the missing file is there and in the correct folder.
-
Re: Applet throw ClassNotFound exception when one of the file is recompiled
Quote:
Originally Posted by
Norm
Use a zip file utility to look inside of the jar file and see if the missing file is there and in the correct folder.
Hi, I did and made sure it is there.
-
Re: Applet throw ClassNotFound exception when one of the file is recompiled
If everything is there and in the correct folder: The class file should be at the top level not in a folder, Then why is java not finding the class?
You edited the error message you posted. Did you leave off some valuable info about where and how the error occurred?
-
Re: Applet throw ClassNotFound exception when one of the file is recompiled
Quote:
Originally Posted by
Norm
If everything is there and in the correct folder: The class file should be at the top level not in a folder, Then why is java not finding the class?
You edited the error message you posted. Did you leave off some valuable info about where and how the error occurred?
I didn't edit anything, i just missed the first line. It is similar to "java.lang.ClassNotFoundException: IORLFCallApplet.class"
The applet is being called in a cold fusion 5 (i know, it is old) file like:
<applet class="IORLFCallApplet" archieve="url/signIORLFCall.jar">
<!-- parameters here -->
</applet>
I wonder if there is anything to do with that I didn't modify the manifest and signature?
-
Re: Applet throw ClassNotFound exception when one of the file is recompiled
Can you make a simple test html file with an applet tag, put the jar in the same folder and load the html file in a browser? Try the code= tag vs class=
<applet code="IORLFCallApplet" archieve="signIORLFCall.jar">
-
Re: Applet throw ClassNotFound exception when one of the file is recompiled
Quote:
Originally Posted by
Norm
Can you make a simple test html file with an applet tag, put the jar in the same folder and load the html file in a browser? Try the code= tag vs class=
<applet code="IORLFCallApplet" archieve="signIORLFCall.jar">
I am sorry, I miss typed it. The code was actually like this:
<APPLET align=center CODE='IORLFCallApplet.class' NAME='IORLFCallApplet' ARCHIVE='SomeURL:8080/lib/signIORLFCall.jar' WIDTH=340 HEIGHT=80 >
</APPLET>
Sorry about that.
-
Re: Applet throw ClassNotFound exception when one of the file is recompiled
Did you try the simple html file to load the applet in a browser?
-
Re: Applet throw ClassNotFound exception when one of the file is recompiled
Quote:
Originally Posted by
Norm
Did you try the simple html file to load the applet in a browser?
Yes, its the same error:
load: class IORLFCallApplet.class not found
java.lang.ClassNotFoundException: IORLFCallApplet.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Un known Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(U nknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unk nown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unk nown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionR unnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
-
Re: Applet throw ClassNotFound exception when one of the file is recompiled
Quote:
IORLFCallApplet.class
It is looking for a file named: IORLFCallApplet.class.class. The browser thinks the class name is class and that it is in the IORLFCallApplet package.
Remove the .class from the code= attribute
-
Re: Applet throw ClassNotFound exception when one of the file is recompiled
Quote:
Originally Posted by
Norm
Did you try the simple html file to load the applet in a browser?
and it did take much much longer than before since it is taking time to look for that class file. ...
-
Re: Applet throw ClassNotFound exception when one of the file is recompiled
Ok, I'm glad you figured it out.
-
Re: Applet throw ClassNotFound exception when one of the file is recompiled
Quote:
Originally Posted by
Norm
Ok, I'm glad you figured it out.
no sorry i didn't figure it out. It still shows the same thing.
one weird thing is that when i put the original jar file back, it just works....
-
Re: Applet throw ClassNotFound exception when one of the file is recompiled
Quote:
Originally Posted by
Norm
Ok, I'm glad you figured it out.
But I highly agree with you it surely looks for some names that are messed up. BTW, IE8 was used for browsing, so applet was not technically supported, it just calls the java plug-in.
-
Re: Applet throw ClassNotFound exception when one of the file is recompiled
What was the error message when you removed the .class from the code= tag?
-
Re: Applet throw ClassNotFound exception when one of the file is recompiled
Quote:
Originally Posted by
Norm
What was the error message when you removed the .class from the code= tag?
If simply changes the code="IORALFCallApplet", the error message remains the same exception wherever the error message mentions the class name, it will only mention "IORALFCallApplet" instead of "IORALFCallApplet.class".
However, i did something else to test it. I added the codebase attribute to point to the url, and just let the "archive" only contains the jar file's name "signIORLFCall.jar". But this time, seems like IORALFCallApplet is found but other classes inside the jar files become invisible:
Java Plug-in 1.6.0_24
Using JRE version 1.6.0_24-b07 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\13560
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/pdf/AwsPdfTemplateException
at sun.plugin2.applet.Plugin2Manager.createApplet(Unk nown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionR unnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: com/pdf/AwsPdfTemplateException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unk nown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$12.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectio nPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.pdf.AwsPdfTemplateException
at sun.plugin2.applet.Applet2ClassLoader.findClass(Un known Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(U nknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 20 more
Exception: java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/pdf/AwsPdfTemplateException
-
Re: Applet throw ClassNotFound exception when one of the file is recompiled
What is in the simple html file you were using?
Were the html file and the jar files in the same folder? You shouldn't need a codebase= if they are together.
-
Re: Applet throw ClassNotFound exception when one of the file is recompiled
Quote:
Originally Posted by
Norm
What is in the simple html file you were using?
Were the html file and the jar files in the same folder? You shouldn't need a codebase= if they are together.
This error is not from the simple file I am using because the applet runs on a services that needs special clients authentication. No they are not in the same directory, they are in different partitions.
-
Re: Applet throw ClassNotFound exception when one of the file is recompiled
Ok. I guess I have no more ideas.
good luck.
-
Re: Applet throw ClassNotFound exception when one of the file is recompiled
Quote:
Originally Posted by
Norm
Ok. I guess I have no more ideas.
good luck.
Thank you very much for your help tho. At least I think I figured something out (not all obviously) with your help. Thanks again.
-
Re: Applet throw ClassNotFound exception when one of the file is recompiled
Did anyone else figure out what the problem could be? I still haven't ....
-
Re: Applet throw ClassNotFound exception when one of the file is recompiled
Have you ever tried putting everything in one test folder and testing it there?
What happened?