GWT – java.lang.NoClassDefFoundError bei der Verwendung von .jars mit 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_clickDiese Exception kann auftreten, wenn man versucht ein externes .jar mit GWT für die Serverseite zu verwenden. Die Fehlermeldung sagt aus, daß der eingebundene Pfad zu dem .jar (in diesem Fall org.jibble.pircbot.PircBot) nicht gefunden werden kann. Dies passiert normalerweise nur dann, wenn der Pfad zu dem .jar im JAVA Build Path nicht gesetzt wurde. Wenn man mit GWT arbeitet, ist das aber leider nicht alles was getan werden muß:

Der übliche Weg ein .jar einzubinden ist, die Einstellungen des Projektes zu bearbeiten, indem man mit der rechtenProject Properties Maustaste auf das Projekt klickt und aus dem PopUp-Menu “Eigenschaften” oder “Properties” wählt. In dem erscheinenden Fenster wählt man dann “Java Build Path” und ergänzt hier dann die externen .jars.

Wenn man das GWT-Plugin für eclipse verwendet, dann ist das nicht die einzige Stelle wo das .jar ergänzt werden muß. Zusätzlich muß hier das .jar noch in das WAR-Verzeichnis des Projektes kopiert werden. Um genau zu sein muß das .jar in folgendem Pfad abgelegt werden: YouProject/war/WEB-INF/lib/.

Nachdem man das .jar dort abgelegt hat, wird die lokale GWT-Runtime ohne weitere Fehlermeldung funktionieren. Der Hintergrund dazu ist folgender: Die GWT-Runtime des eclipse Plugins verwendet nicht die eclipse-Umgebung, sondern läuft ausschließlich aus dem “war”-Verzeichnis des Projektes, welches später auch auf den Application-Server deployed wird.

If you enjoyed this post, make sure you subscribe to my RSS feed!

14 Antworten auf GWT – java.lang.NoClassDefFoundError bei der Verwendung von .jars mit eclipse

  • BETTY sagt:

    I’ve been looking all over for this!

    Thanks.

  • Shveta sagt:

    It was helpful.Thanks.

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

  • admin sagt:

    @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.

  • Bunyamın sagt:


    ı 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?

  • admin sagt:

    @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.

  • Bunyamın sagt:

    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

  • Bunyamın sagt:

    i start to server side so its look like okey
    thank you very much

  • admin sagt:

    @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.

  • ScriKi sagt:

    Thanks a lot!

  • Sv3nn3er sagt:

    Erik you are great!! I have this problem since 2 weeks now and GWT help didnt say anything about it… :/
    Hope to hear a lot about GWT and other stuff in future!

    Grüße aus Dresden

  • gwthappyman sagt:

    You are FANTASTIC! Thanks you saved my day

  • Suru sagt:

    Great, buddy! You’ve save MANY people’s day.

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

*

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Get in contact:

Kategorien