简体   繁体   中英

NoClassDefFoundError hibernate criterion exporting jar

I'm trying to export a java stand-alone class that uses hibernate. It's a really simple read/insert procedure. I'm stuck with this error

C:\Users\Admin\Desktop>java -jar ImportDatiMeteo2.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/hibernate/criteri
on/Criterion
        at openplan.openergy.standalone.ImportDati.main(ImportDati.java:24)
Caused by: java.lang.ClassNotFoundException: org.hibernate.criterion.Criterion
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 1 more

I was thinking it could be a manifest file problem so i checked. It seem ok to me.

Manifest-Version: 1.0
Class-Path: lib/antlr-2.7.6rc1.jar lib/asm-attrs.jar lib/asm.jar 
 lib/c3p0-0.8.5.2.jar lib/cglib-2.1.3.jar lib/cleanimports.jar 
 lib/commons-collections-2.1.1.jar lib/commons-logging-1.0.4.jar lib/concurrent-1.3.2.jar
 lib/connector.jar lib/dom4j-1.6.1.jar lib/ehcache-1.1.jar lib/hibernate3.jar
 lib/jaas.jar lib/jacc-1_0-fr.jar lib/jaxen-1.1-beta-7.jar
 lib/jdbc2_0-stdext.jar lib/jgroups-2.2.7.jar lib/jta.jar lib/log4j-1.2.11.jar
 lib/log4j-1.2.9.jar lib/oscache-2.1.jar lib/proxool-0.8.3.jar
 lib/swarmcache-1.0rc2.jar lib/xerces-2.6.2.jar lib/xml-apis.jar  
Created-By: 1.6.0_21 (Sun Microsystems Inc.)
Main-Class: openplan.openergy.standalone.ImportDati

In my Eclipse all the project work properly, does anyone know where the problem is?

You need to add those libraries in classpath as you are running it from command line :

C:\> java -classpath <referenced-jars> -jar ImportDatiMeteo2.jar

in myEclipse all the project work properly, does anyone know where the problem is ?

--> Because Eclipse will take care of your classpath and adding libraries in your classpath.

Please check Library handling option in your Eclipse export dialog. On my side it works fine with hibernate with Extract required libraries into generated JAR selected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM