hibernate - Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org/hiber nate/cfg/Configuration -
i created project in eclipse , executed succesfuly (it's normal project, without maven or beans, simple), created .jar project , tried execute throws following error:
c:\documents\wrapper-windows-x86-64-3.5.19-st\bin>java -cp quotehandler.jar stoc k.view.main initial sessionfactory creation failed.java.lang.noclassdeffounderror: org/hiber nate/cfg/configuration exception in thread "quotes" java.lang.exceptionininitializererror @ stock.controller.hollidaycontroller.<clinit>(hollidaycontroller.java: 25) @ stock.view.mainthread.run(mainthread.java:57) @ java.lang.thread.run(unknown source) caused by: java.lang.noclassdeffounderror: org/hibernate/cfg/configuration @ stock.controller.hollidaycontroller.<clinit>(hollidaycontroller.java: 22) ... 2 more caused by: java.lang.classnotfoundexception: org.hibernate.cfg.configuration @ java.net.urlclassloader$1.run(unknown source) @ java.net.urlclassloader$1.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(unknown source) @ java.lang.classloader.loadclass(unknown source) @ sun.misc.launcher$appclassloader.loadclass(unknown source) @ java.lang.classloader.loadclass(unknown source) ... 3 more
the .classpath file of project has:
<?xml version="1.0" encoding="utf-8"?> <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.jre_container/org.eclipse.jdt.internal.debug.ui.launcher.standardvmtype/jre7"/> <classpathentry kind="lib" path="lib/antlr-2.7.7.jar"/> <classpathentry kind="lib" path="lib/dom4j-1.6.1.jar"/> <classpathentry kind="lib" path="lib/hibernate-commons-annotations-4.0.1.final.jar"/> <classpathentry kind="lib" path="lib/hibernate-core-4.1.10.final.jar" sourcepath="lib/hibernate-core-4.1.10.final.jar"/> <classpathentry kind="lib" path="lib/hibernate-entitymanager-4.1.10.final.jar"/> <classpathentry kind="lib" path="lib/hibernate-jpa-2.0-api-1.0.1.final.jar"/> <classpathentry kind="lib" path="lib/javassist-3.15.0-ga.jar"/> <classpathentry kind="lib" path="lib/jboss-logging-3.1.0.ga.jar"/> <classpathentry kind="lib" path="lib/jboss-transaction-api_1.1_spec-1.0.0.final.jar"/> <classpathentry kind="lib" path="lib/mysql-connector-java-5.1.20-bin.jar"/> <classpathentry kind="lib" path="lib/org.springframework.beans_3.1.4.release.jar"/> <classpathentry kind="lib" path="lib/org.springframework.web_3.1.4.release.jar"/> <classpathentry kind="lib" path="lib/org.springframework.context_3.1.4.release.jar"/> <classpathentry kind="lib" path="lib/joda-time-2.2.jar"/> <classpathentry kind="lib" path="lib/c3p0-0.9.1.jar"/> <classpathentry kind="output" path="bin"/> </classpath>
checking on internet modify %classpath% variable to:
classpath = c:\program files\java\jre7\lib;c:\program files\java\jre7\lib\c3p0-0.9.1.jar
all references configured in build path of project , works, when i'm executing .jar doesn't work (all references included in jar). missing?
try following option eclipse:
- file->export
- from wizard select java->runnable jar file
- click next
- select launch configuration: select class main() method, if not available here try run program once in eclipse
- export destination: select full path jar file
- library handling: select third 1 "copy required lib..."
- click on finish
go command prompt , change dir exported jar file , type java -jar <exported_jar>.jar
one note: in java classpath lib/* not resolve jars in directory, have type each , every jar entry manually.
Comments
Post a Comment