4 Replies Latest reply: Dec 2, 2011 1:36 PM by 903387 RSS

    Deploying applet with multiple jar files

    903387
      I am trying to deploy an applet that references two jars: helloworld.jar (the main class) and d20.jar (an external library). Both jars have been added to the applet archive parameter, and the HTML doc, jnlp, and both jar files are kept in the same folder when deployed. I keep getting a java.lang.NoClassDefFoundError when trying to load the d20.jar file. I can't figure out what I'm doing wrong. My code is below.

      Thanks for any help given.

      The applet tag:
      <applet 
          code="jogl.HelloWorld"
          codebase="."
          width=512
          height=256
          archive="helloworld.jar,d20.jar">
        <param name="jnlp_href" value="HelloWorldJNLP.jnlp">
      </applet>
      The JNLP file:
      <?xml version="1.0" encoding="UTF-8"?>
      <jnlp spec="1.0+" codebase="" href="">
        <information>
          <title>Hello World</title>
          <description kind="short">
            First Applet
          </description>
          <offline-allowed/>
        </information>
        <resources>
          <!-- Application Resources -->
          <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
          <jar href="helloworld.jar" main="true" />
        </resources>
        <applet-desc
          name="Hello World"
          main-class="jogl.HelloWorld"
          width="512"
          height="256">
        </applet-desc>
        <update check="background" policy="always"/>
      </jnlp>
      The console output:
      java.lang.reflect.InvocationTargetException
           at java.awt.EventQueue.invokeAndWait(Unknown Source)
           at javax.swing.SwingUtilities.invokeAndWait(Unknown Source)
           at jogl.HelloWorld.init(HelloWorld.java:18)
           at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
           at java.lang.Thread.run(Unknown Source)
      Caused by: java.lang.NoClassDefFoundError: com/dalonedrau/d20/Diceroller
           at jogl.HelloWorld$1.run(HelloWorld.java:21)
           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.doIntersectionPrivilege(Unknown Source)
           at java.awt.EventQueue.dispatchEvent(Unknown Source)
           at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
           at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
           at java.awt.EventDispatchThread.pumpEventsForHierarchy(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.dalonedrau.d20.Diceroller
           at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source)
           at java.security.AccessController.doPrivileged(Native Method)
           at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source)
           at sun.plugin2.applet.JNLP2ClassLoader.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)
           ... 15 more
        • 1. Re: Deploying applet with multiple jar files
          817264
          JNLP file is missing
          <jar href="d20.jar"/>
          • 2. Re: Deploying applet with multiple jar files
            903387
            Thanks, igor, but I tried that before, adding it to resources. Still gives the same error.

            the updated jnlp:
            <?xml version="1.0" encoding="UTF-8"?>
            <jnlp spec="1.0+" codebase="" href="">
                 <information>
                      <title>Hello World</title>
                      <description kind="short">
                           First Applet
                      </description>
                      <offline-allowed/>
                </information>
                 <resources>
                      <!-- Application Resources -->
                      <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
                      <jar href="helloworld.jar" main="true" />
                      <jar href="d20.jar" />
                 </resources>
                 <applet-desc
                      name="Hello World"
                      main-class="test.HelloWorld"
                      width="512"
                      height="256">
                 </applet-desc>
                 <update check="background" policy="always"/>
            </jnlp>
            • 3. Re: Deploying applet with multiple jar files
              817264
              Enable detailed trace and post result here (http://docs.oracle.com/javase/7/docs/webnotes/tsg/TSG-Desktop/html/plugin.html#gcexdf).

              Also port jar content for d20.jar - do you actually have class with this name in the jar?
              • 4. Re: Deploying applet with multiple jar files
                903387
                igor,

                Thanks for the tip about the trace. Turns out the deployment was saved in the Java cache, so changes to the JNLP file weren't being loaded.