This discussion is archived
3 Replies Latest reply: Mar 30, 2012 9:01 AM by 802471 RSS

JNLP throws java.lang.NoClassDefFoundError

802471 Newbie
Currently Being Moderated
Hello,

I started playing around with Web Start and got it running with a simple app, which just shows a empty frame. Now when I tried to run more complex app with libraries I get the error:

java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpException
     at java.lang.Class.getDeclaredMethods0(Native Method)
     at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
     at java.lang.Class.getMethod0(Unknown Source)
     at java.lang.Class.getMethod(Unknown Source)
     at com.sun.javaws.Launcher.executeApplication(Unknown Source)
     at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
     at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
     at com.sun.javaws.Launcher.run(Unknown Source)
     at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.HttpException
     at java.net.URLClassLoader$1.run(Unknown Source)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.net.URLClassLoader.findClass(Unknown Source)
     at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
     ... 9 more

The HttpException should be in the commons-httpclient.jar listed in the jnlp. My .jnlp file is:
<?xml version="1.0" encoding="UTF-8"?>
<jnlp href="launch.jnlp" spec="1.0+" codebase="https://localhost:8443/mytest/">
     <information>
          <title>MyTest</title>
          <vendor>A Company, Inc.</vendor>
          <description>MyTest</description>
          <description kind="short">MyTest</description>
     </information>
     <update check="always"/>
     <security>
          <all-permissions/>
     </security>
     <resources>
          <!--<j2se version="1.6+"/>-->
          <jar href="MyTest.jar" main="true"/>
          <jar href="lib/MyLibrary.jar"/>
          <jar href="lib/nachocalendar-0.23.jar"/>
          <jar href="lib/antlr.jar"/>
          <jar href="lib/commons-httpclient-contrib.jar"/>
          <jar href="lib/commons-httpclient.jar"/>
          <jar href="lib/commons-logging.jar"/>
          <jar href="lib/commons-transaction-1.0.jar"/>
          <jar href="lib/jakarta-slide-commandline-2.1.jar"/>
          <jar href="lib/jakarta-slide-webdavlib-2.1.jar"/>
          <jar href="lib/jdom-1.0.jar"/>
          <jar href="lib/xml-im-exporter1.1.jar"/>
          <jar href="lib/postgresql-9.1-901.jdbc4.jar"/>
     </resources>
     <application-desc main-class="nt.gui.LoginScreenGUI">
     </application-desc>
</jnlp>
My error is something similar to Re: Extra jar fetched but not loaded ? but the post doesn't seem to have a solution. I'm currently using Tomcat 7 as the webserver and running JDK 1.6.0_31. Any help would be much appreciated. Thanks.
  • 1. Re: JNLP throws java.lang.NoClassDefFoundError
    817614 Explorer
    Currently Being Moderated
    It would help you debug your app if you turn on tracing by adding the following lines in <user-home>/Java/deployment/deployment.properties file:
    deployment.trace=true
    deployment.trace.level=all
    deployment.console.startup.mode=SHOW

    Also try latest JRE 7 early access build to see if it solves your problem:
    http://jdk7.java.net/download.
  • 2. Re: JNLP throws java.lang.NoClassDefFoundError
    817614 Explorer
    Currently Being Moderated
    BTW, here some trouble-shooting guide to help developer debugging issues with webstart and applets:
    http://docs.oracle.com/javase/7/docs/webnotes/tsg/TSG-Desktop/html/plugin.html
  • 3. Re: JNLP throws java.lang.NoClassDefFoundError
    802471 Newbie
    Currently Being Moderated
    Thanks for replying.

    I've added that to the .properties file but it did little to help, at least for me. However, somehow I ended up rebuilding my jar file with 1.6.0_31 from 1.6.0_26 and that fixed whatever problem I had (don't think it's corruption since I've done multiple builds with 1.6.0_26 and deployed it); my server was running 1.6.0_31 while my IDE was still using 1.6.0_26.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points