1 2 Previous Next 17 Replies Latest reply: Dec 8, 2011 3:14 PM by 817264 RSS

    Java applets and Apache

    903776
      I'm having an issue with a page containing an applet loading.

      When I load the html file by simply dropping it into my browser, the java applet loads perfectly fine (File:///testFile.html).

      When I load the html file via address bar (http://localhost/testFile.html) I get an exception: java.lang.ClassNotFoundException

      I'm nearly certain this is an apache issue however I really don't know where to begin.

      My understanding of the "cache entry not found" issue is that it means that it can't find the jar files. I've c/p'd the url into my address bar and it begins downloading the file, so I know the file is there.

      My first instinct was to check the mime types so I added this to my mime.types: application/x-java-applet

      Running apache 2.2.4

      signedAppletTest.jar is the applet and dpotapi.jar and dpotjni.jar are additional libraries.
      Here is the debug from the java console:
      -----
      Detected from bootclasspath: C:\\PROGRA~1\\Java\\jre7\\lib\\deploy.jar
      basic: Added progress listener: sun.plugin.util.ProgressMonitorAdapter@1b6dd83
      basic: Plugin2ClassLoader.addURL parent called for http://localhost/trunk/app/views/test/signedAppletTest.jar
      basic: Plugin2ClassLoader.addURL parent called for http://localhost/trunk/app/views/test/dpotapi.jar
      basic: Plugin2ClassLoader.addURL parent called for http://localhost/trunk/app/views/test/dpotjni.jar
      network: Cache entry not found [url: http://localhost/trunk/app/views/test/signedAppletTest.jar, version: null]
      network: Connecting http://localhost/trunk/app/views/test/signedAppletTest.jar with proxy=DIRECT
      network: Connecting http://localhost:80/ with proxy=DIRECT
      network: Cache entry not found [url: http://localhost/trunk/app/views/test/signedAppletTest.jar, version: null]
      network: Cache entry not found [url: http://localhost/trunk/app/views/test/signedAppletTest.jar, version: null]
      network: Connecting http://localhost/trunk/app/views/test/signedAppletTest.jar with proxy=DIRECT
      network: Connecting http://localhost:80/ with proxy=DIRECT
      network: Connecting http://localhost/trunk/app/views/test/signedAppletTest.jar with proxy=DIRECT
      network: Connecting http://localhost:80/ with proxy=DIRECT
      network: Cache entry not found [url: http://localhost/trunk/app/views/test/dpotapi.jar, version: null]
      network: Connecting http://localhost/trunk/app/views/test/dpotapi.jar with proxy=DIRECT
      network: Connecting http://localhost:80/ with proxy=DIRECT
      network: Cache entry not found [url: http://localhost/trunk/app/views/test/dpotapi.jar, version: null]
      network: Cache entry not found [url: http://localhost/trunk/app/views/test/dpotapi.jar, version: null]
      network: Connecting http://localhost/trunk/app/views/test/dpotapi.jar with proxy=DIRECT
      network: Connecting http://localhost:80/ with proxy=DIRECT
      network: Connecting http://localhost/trunk/app/views/test/dpotapi.jar with proxy=DIRECT
      network: Connecting http://localhost:80/ with proxy=DIRECT
      network: Cache entry not found [url: http://localhost/trunk/app/views/test/dpotjni.jar, version: null]
      network: Connecting http://localhost/trunk/app/views/test/dpotjni.jar with proxy=DIRECT
      network: Connecting http://localhost:80/ with proxy=DIRECT
      network: Cache entry not found [url: http://localhost/trunk/app/views/test/dpotjni.jar, version: null]
      network: Cache entry not found [url: http://localhost/trunk/app/views/test/dpotjni.jar, version: null]
      network: Connecting http://localhost/trunk/app/views/test/dpotjni.jar with proxy=DIRECT
      network: Connecting http://localhost:80/ with proxy=DIRECT
      network: Connecting http://localhost/trunk/app/views/test/dpotjni.jar with proxy=DIRECT
      network: Connecting http://localhost:80/ with proxy=DIRECT
      network: Cache entry not found [url: http://localhost/trunk/app/views/test/signedAppletTest.jar, version: null]
      network: Connecting http://localhost/trunk/app/views/test/signedAppletTest.jar with proxy=DIRECT
      network: Connecting http://localhost:80/ with proxy=DIRECT
      network: Cache entry not found [url: http://localhost/trunk/app/views/test/signedAppletTest.jar, version: null]
      network: Cache entry not found [url: http://localhost/trunk/app/views/test/signedAppletTest.jar, version: null]
      network: Connecting http://localhost/trunk/app/views/test/signedAppletTest.jar with proxy=DIRECT
      network: Connecting http://localhost:80/ with proxy=DIRECT
      network: Connecting http://localhost/trunk/app/views/test/signedAppletTest.jar with proxy=DIRECT
      network: Connecting http://localhost:80/ with proxy=DIRECT
      network: Cache entry not found [url: http://localhost/trunk/app/views/test/dpotapi.jar, version: null]
      network: Connecting http://localhost/trunk/app/views/test/dpotapi.jar with proxy=DIRECT
      network: Connecting http://localhost:80/ with proxy=DIRECT
      network: Cache entry not found [url: http://localhost/trunk/app/views/test/dpotapi.jar, version: null]
      network: Cache entry not found [url: http://localhost/trunk/app/views/test/dpotapi.jar, version: null]
      network: Connecting http://localhost/trunk/app/views/test/dpotapi.jar with proxy=DIRECT
      network: Connecting http://localhost:80/ with proxy=DIRECT
      network: Connecting http://localhost/trunk/app/views/test/dpotapi.jar with proxy=DIRECT
      network: Connecting http://localhost:80/ with proxy=DIRECT
      network: Cache entry not found [url: http://localhost/trunk/app/views/test/dpotjni.jar, version: null]
      network: Connecting http://localhost/trunk/app/views/test/dpotjni.jar with proxy=DIRECT
      network: Connecting http://localhost:80/ with proxy=DIRECT
      network: Cache entry not found [url: http://localhost/trunk/app/views/test/dpotjni.jar, version: null]
      network: Cache entry not found [url: http://localhost/trunk/app/views/test/dpotjni.jar, version: null]
      network: Connecting http://localhost/trunk/app/views/test/dpotjni.jar with proxy=DIRECT
      network: Connecting http://localhost:80/ with proxy=DIRECT
      network: Connecting http://localhost/trunk/app/views/test/dpotjni.jar with proxy=DIRECT
      network: Connecting http://localhost:80/ with proxy=DIRECT
      basic: Plugin2ClassLoader.isTrustedByPolicy called
      basic: Plugin2ClassLoader.isTrustedByPolicy returns false
      network: Cache entry not found [url: http://localhost/trunk/app/views/test/applettest/AppletTest.class, version: null]
      network: Connecting http://localhost/trunk/app/views/test/applettest/AppletTest.class with proxy=DIRECT
      network: Connecting http://localhost:80/ with proxy=DIRECT
      network: Cache entry not found [url: http://localhost/trunk/app/views/test/applettest/AppletTest.class, version: null]
      network: Connecting http://localhost/trunk/app/views/test/applettest/AppletTest.class with proxy=DIRECT
      network: Connecting http://localhost:80/ with proxy=DIRECT
      java.lang.ClassNotFoundException: applettest.AppletTest
           at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
           at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
           at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
           at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
           at java.lang.ClassLoader.loadClass(Unknown Source)
           at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
           at sun.plugin2.applet.Plugin2Manager.initAppletAdapter(Unknown Source)
           at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
           at java.lang.Thread.run(Unknown Source)
      basic: load: class applettest.AppletTest not found.
      java.lang.ClassNotFoundException: applettest.AppletTest
           at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
           at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
           at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
           at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
           at java.lang.ClassLoader.loadClass(Unknown Source)
           at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
           at sun.plugin2.applet.Plugin2Manager.initAppletAdapter(Unknown Source)
           at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
           at java.lang.Thread.run(Unknown Source)
      Ignored exception: java.lang.ClassNotFoundException: applettest.AppletTest
      basic: Removed progress listener: sun.plugin.util.ProgressMonitorAdapter@1b6dd83
      security: Accessing keys and certificate in Mozilla user profile: null
      security: Reset deny session certificate store
      -----

      this is literally my first java project ever so I'm completely inexperienced. Thanks in advance.
        • 1. Re: Java applets and Apache
          817264
          Post how you deploy applet in the html too.

          From the log it seem you specify full paths to jars in the HTML and it will not work when you host applet over http.
          Path for jar files need to be relative to the html page location.
          • 2. Re: Java applets and Apache
            903776
            This is my applet tag:

            <applet code="applettest.AppletTest" archive="signedAppletTest.jar, dpotapi.jar, dpotjni.jar" name="applettest">
                 <param name="separate_jvm" value="true" />
            </applet>
            • 3. Re: Java applets and Apache
              817264
              Hmm, why would it request
              http://localhost/trunk/app/views/test/signedAppletTest.jar
              if your web page is at
              http://localhost/testFile.html
              ?

              Do you have redirect or change document base using javascript?
              Or may be apache returning wrong "path" in the http response.

              Try installing http sniffer and check what network requests are being made.
              (e.g. wireshark)
              • 4. Re: Java applets and Apache
                903776
                Sorry...I was using that as a very bare example of the two different ways I was accessing the file.

                The actual address of the file is: http://localhost/trunk/app/views/test/fingerPrintTest.html
                • 5. Re: Java applets and Apache
                  817264
                  1) what jar actually contains applettest.AppletTest?
                  Could you post content of the jar here?
                  (output of "jar tf filename.jar")

                  2) Try opening http://localhost/trunk/app/views/test/signedAppletTest.jar in the browser
                  Does it offer to load jar of fails as file not found? (if later then you need to fix apache config or put jars next to html)

                  3) Enable detailed trace log and reproduce the issue again. Post detailed log here (unless you figure it yourself)
                  http://docs.oracle.com/javase/7/docs/webnotes/tsg/TSG-Desktop/html/plugin.html#gcexdf
                  • 6. Re: Java applets and Apache
                    903776
                    1.)
                    C:\Users\billy\Desktop>jar tf signedAppletTest.jar
                    META-INF/MANIFEST.MF
                    META-INF/BILLY.SF
                    META-INF/BILLY.DSA
                    META-INF/
                    applettest/
                    applettest/AppletTest$1.class
                    applettest/AppletTest$2.class
                    applettest/AppletTest$dpstate.class
                    applettest/AppletTest.class

                    2.) It prompts me to download the jar

                    3.)
                    trace: http://pastebin.com/jnMJHTMK
                    Log: http://pastebin.com/TvpJ1MXh

                    And just for reference...here is the trace and log for when I load it not through apache (and it works)
                    trace: http://pastebin.com/ZcU644ba
                    Log: http://pastebin.com/RukiB7LW


                    Thank you again for spending time to help me through this...
                    • 7. Re: Java applets and Apache
                      817264
                      One thing i note is that for non-JNLP applet separate_jvm parameter make no sense and i think you need to specify width and height attribute for the applet.
                      See http://docs.oracle.com/javase/1.4.2/docs/guide/misc/applet.html
                      2.) It prompts me to download the jar
                      Use wire shark to see what is http response for this request.
                      It does not seem that jar was properly loaded/handled as in that case you would see "content-length" printed for downloaded file.
                      • 8. Re: Java applets and Apache
                        903776
                        I went ahead and made the changes you've suggested to my applet tag...still no luck.

                        I'm a little lost on how to use wireshark to get the http response...anyway you could give me some instructions on that? When I set it to capture on my interface, I'm not seeing any headers, at least not for the download...I'm wondering if it's maybe because I'm on the same machine as my apache server?
                        • 9. Re: Java applets and Apache
                          EJP
                          It seems to me that the real issue here is the contents of the directory that contains the .html file. As you haven't specified a codebase attribute, it defaults to that directory. Which must therefore contain the .JAR file too. Does it?
                          • 10. Re: Java applets and Apache
                            903776
                            I went ahead and specified the codebase param and still am getting the same error. All necessary jars are in the same folder as the html.
                            • 11. Re: Java applets and Apache
                              817264
                              i do not have local web server right now and therefore could not check steps for wireshark.
                              Lets start with simple experiment.

                              Do you have Firefox? Install Tamper Data extension, open it in the Tools menu and then enter full URL for the jar file in the address bar.
                              Tamper data will show you request/response pair. Paste http response here (at least Content-Type should be "application/java-archive").

                              There are other browser extensions that can capture same data. For IE there are IE Developer tools that can trace requests too if i recall correctly.
                              • 12. Re: Java applets and Apache
                                903776
                                Here is the screen shot of the tamper data results: http://imageshack.us/f/848/tamperdata.png/

                                In short, there is nothing in the response. Those are all 3 calls to localhost, the first two are a result of the download (neither had any information in the response). The third is a call to the page I did just to see if there was anything of note there. I didn't see anything that would have been helpful but I can screen cap that as well.
                                • 13. Re: Java applets and Apache
                                  817264
                                  Clear browser cache first.
                                  Or copy .jar file into file with different name and load new jar.

                                  You need to get server answer for the request. If request is served from browser cache then it does not help us to troubleshoot.
                                  • 14. Re: Java applets and Apache
                                    903776
                                    My apologies, I didn't even think to try clearing the cache to get that information.

                                    Here is the response from an entirely different jar

                                    Status=OK - 200
                                    Date=Wed, 07 Dec 2011 18:45:01 GMT
                                    Server=Apache
                                    Last-Modified=Mon, 05 Dec 2011 17:52:28 GMT
                                    Etag="16d76-837e-fb674adc"
                                    Accept-Ranges=bytes
                                    Content-Length=33662
                                    Content-Type=application/java-archive
                                    X-OSSProxy=OSSProxy 1.3.331.322 (Build 331.322 Win32 en-us)(Oct 11 2011 17:53:42)
                                    Connection=keep-alive
                                    1 2 Previous Next