Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 22 of 22

Thread: Applet throw ClassNotFound exception when one of the file is recompiled

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default 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.

  3. #3
    Junior Member
    Join Date
    Jul 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Applet throw ClassNotFound exception when one of the file is recompiled

    Quote Originally Posted by Norm View Post
    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.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default 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?

  5. #5
    Junior Member
    Join Date
    Jul 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Applet throw ClassNotFound exception when one of the file is recompiled

    Quote Originally Posted by Norm View Post
    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?

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default 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">

  7. #7
    Junior Member
    Join Date
    Jul 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Applet throw ClassNotFound exception when one of the file is recompiled

    Quote Originally Posted by Norm View Post
    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.

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default 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?

  9. #9
    Junior Member
    Join Date
    Jul 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Applet throw ClassNotFound exception when one of the file is recompiled

    Quote Originally Posted by Norm View Post
    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)

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Applet throw ClassNotFound exception when one of the file is recompiled

    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

  11. #11
    Junior Member
    Join Date
    Jul 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Applet throw ClassNotFound exception when one of the file is recompiled

    Quote Originally Posted by Norm View Post
    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. ...

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Applet throw ClassNotFound exception when one of the file is recompiled

    Ok, I'm glad you figured it out.

  13. #13
    Junior Member
    Join Date
    Jul 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Applet throw ClassNotFound exception when one of the file is recompiled

    Quote Originally Posted by Norm View Post
    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....

  14. #14
    Junior Member
    Join Date
    Jul 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Applet throw ClassNotFound exception when one of the file is recompiled

    Quote Originally Posted by Norm View Post
    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.

  15. #15
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default 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?

  16. #16
    Junior Member
    Join Date
    Jul 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Applet throw ClassNotFound exception when one of the file is recompiled

    Quote Originally Posted by Norm View Post
    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

  17. #17
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default 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.

  18. #18
    Junior Member
    Join Date
    Jul 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Applet throw ClassNotFound exception when one of the file is recompiled

    Quote Originally Posted by Norm View Post
    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.

  19. #19
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Applet throw ClassNotFound exception when one of the file is recompiled

    Ok. I guess I have no more ideas.

    good luck.

  20. #20
    Junior Member
    Join Date
    Jul 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Applet throw ClassNotFound exception when one of the file is recompiled

    Quote Originally Posted by Norm View Post
    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.
    Last edited by philwei; July 12th, 2011 at 01:12 PM. Reason: typo

  21. #21
    Junior Member
    Join Date
    Jul 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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 ....

  22. #22
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default 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?

Similar Threads

  1. Calculator Throw Error
    By bengregg in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 5th, 2011, 09:25 PM
  2. Replies: 10
    Last Post: January 12th, 2011, 05:48 AM
  3. applet + swing + arraylist = exception??
    By wolfgar in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 1st, 2010, 11:38 PM
  4. Error of "ClassNotFound Exception"
    By multicoder in forum Exceptions
    Replies: 3
    Last Post: July 1st, 2009, 02:58 PM
  5. exception while Read very large file > 300 MB
    By ps.ganesh in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: June 11th, 2009, 11:39 PM

Tags for this Thread