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)
This 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
appearing 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!
I’ve been looking all over for this!
Thanks.
It was helpful.Thanks.
What about standard java classes like java.util.Calendar? Can you use them in any way?
@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.
Thank you for your answer. I had to change my core classes such that I can use just the emulated objects.
hı
ı want to use openid and i put . jar files about openid as builth path and i copied to ./lib my files but when i start my application its give error where i use something of about my jar fiels.
error is likes
07:17:23.815 [ERROR] [dene16] Line 44: No source code is available for type org.openid4java.discovery.DiscoveryInformation; did you forget to inherit a required module?
can someone help me pls?
@Bunyamın
I’m not sure how or where you want to use this in your project: If you are trying to use this on the “client-side”, the Google App Engine will prevent this library from working, since it is not supported as far as I know. If you are trying to use it as an servlet, you must additionally add the servlet to your web.xml. Please feel free to contact me again, if this does not help you.
client or servlet actually we are prepering a project for our class and we are using gwt-ext also we have to add hibernate and openid tecnology i am trying use openid4java.jar files but its not working and other .jar files too
cant i use a external . jar files?
so for example there are GHchart.jar but its has GHchart.gwt.xml so i can use in myapplicatin.gwt.xml its okey
but openid4java doesnt have a .gwt.xml i think i have to write my open4javabunal.gwt.xml
after this solve i will try to work server-side actually i trying on this proplem over 1 week
i start to server side so its look like okey
thank you very much
@Bunyamın
On the client (frontend) side, you won’t be able to use these jars. On the server-side it should work without any problems – as far as I understand, you tried to use them client-side: but jars can not be translated into AJAX up to now.