Home > GWT > GWT – java.lang.NoClassDefFoundError when using .jars with eclipse

GWT – java.lang.NoClassDefFoundError when using .jars with eclipse

10.12.2009 19:19:19 com.google.apphosting.utils.jetty.JettyLogger warn
WARNUNG: Nested in javax.servlet.ServletException: init:
java.lang.NoClassDefFoundError: org/jibble/pircbot/PircBot
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:675)

project_right_clickThis exception can occure, when you try to use an .jar with GWT on the server side. The error message tells you, that the included path to your .jar (in this case org.jibble.pircbot.PircBot) can not be found. This normally happens, when you have forgotten to put the .jar into your build-path. When running GWT, the normal include into the build-path is not everything you need to do:

The normal way to include the .jar to your build-path is to edit the properties of your project, by right-clicking your project. In the Project Propertiesappearing window, you select “Java Build Path”. There you normally add your external .jars.

When using the GWT-Plugin in eclipse, this isn’t the only thing you have to do. Additionally, you need to copy the .jar into the WAR-directory of your project. The exact path is: YouProject/war/WEB-INF/lib/.

After putting the .jar into this directory, your local GWT-Runtime will work and not throw this error again. The reason is, that the GWT-Runtime of eclipse does not use the eclipse environment. It uses only the files of your “war”, which will be deployed to your application-server later.

If you enjoyed this post, make sure you subscribe to my RSS feed!
Categories: GWT Tags: , , , ,
  1. BETTY
    02:54 AM at 02:54 AM | #1

    I’ve been looking all over for this!

    Thanks.

  2. Shveta
    12:49 PM at 12:49 PM | #2

    It was helpful.Thanks.

  3. 04:23 PM at 04:23 PM | #3

    What about standard java classes like java.util.Calendar? Can you use them in any way?

  4. 05:36 PM at 05:36 PM | #4

    @Tiberiu: Yes – on Serverside, you can use all Java-Classes. On the client Side not all classes are in GWT – only the commonly used classes in the Java standard class library can be used (such as most of the java.lang package classes and a subset of the java.util package classes). Have a look at the JRE Emulation Library http://www.gwtapps.com/doc/html/jre.html for further details.

  1. No trackbacks yet.