- This topic has 6 replies, 3 voices, and was last updated 16 years, 9 months ago by raj82.
-
AuthorPosts
-
Curt KingParticipantI’m working through the Hibernate tutorial. I’ve built an Ant build.xml file that runs my application, but I get this error when I run Ant:
run:
[java] java.lang.NoClassDefFoundError: org/hibernate/Session
[java] Exception in thread “main”
[java] Java Result: 1I know that this package exists in the hibernate3.jar file. I’ve added all of the Hibernate jars to my project’s build path and to the classpath in my configuration for build.xml.
Any ideas why the java executable wouldn’t be finding this package?
Thanks,
Curt
Haris PecoMemberCurt,
Please, can you send your build.xml and how you call it
Thanks
Curt KingParticipantHere’s my build.xml file:
<project name="hibernate-tutorial" default="compile"> <property name="sourcedir" value="${basedir}/src"/> <property name="targetdir" value="${basedir}/bin"/> <property name="librarydir" value="${basedir}/lib"/> <path id="libraries"> <fileset dir="${librarydir}"> <include name="*.jar"/> </fileset> </path> <target name="clean"> <delete dir="${targetdir}"/> <mkdir dir="${targetdir}"/> </target> <target name="compile" depends="clean, copy-resources"> <javac srcdir="${sourcedir}" destdir="${targetdir}" classpathref="libraries"/> </target> <target name="copy-resources"> <copy todir="${targetdir}"> <fileset dir="${sourcedir}"> <exclude name="**/*.java"/> </fileset> </copy> </target> <target name="run" depends="compile"> <java fork="true" classname="events.EventManager" classpathref="libraries"> <classpath path="${targetdir}"/> <arg value="${action}"/> </java> </target> </project>
I’m calling it by right-clicking on it and going to Run As… / Ant Build. I’ve created a configuration for it in the External Tools dialog. I’ve added all of the Hibernate jars to the “Classpath” tab of the Ant Build configuration (hibernate3.jar plus all of the jars from /lib).
Here’s the output of the build:
Buildfile: E:\Eclipse Source\HibernateTest\build.xml clean: [delete] Deleting directory E:\Eclipse Source\HibernateTest\bin [mkdir] Created dir: E:\Eclipse Source\HibernateTest\bin copy-resources: [copy] Copying 3 files to E:\Eclipse Source\HibernateTest\bin [copy] Copied 2 empty directories to 1 empty directory under E:\Eclipse Source\HibernateTest\bin compile: [javac] Compiling 3 source files to E:\Eclipse Source\HibernateTest\bin clean: [delete] Deleting directory E:\Eclipse Source\HibernateTest\bin [mkdir] Created dir: E:\Eclipse Source\HibernateTest\bin copy-resources: [copy] Copying 3 files to E:\Eclipse Source\HibernateTest\bin [copy] Copied 2 empty directories to 1 empty directory under E:\Eclipse Source\HibernateTest\bin clean: [delete] Deleting directory E:\Eclipse Source\HibernateTest\bin [mkdir] Created dir: E:\Eclipse Source\HibernateTest\bin copy-resources: [copy] Copying 3 files to E:\Eclipse Source\HibernateTest\bin [copy] Copied 2 empty directories to 1 empty directory under E:\Eclipse Source\HibernateTest\bin compile: [javac] Compiling 3 source files to E:\Eclipse Source\HibernateTest\bin run: [java] java.lang.NoClassDefFoundError: org/hibernate/Session [java] Exception in thread "main" [java] Java Result: 1 BUILD SUCCESSFUL Total time: 5 seconds
If you need anything else, please let me know!
Thanks for your help,
Curt
Haris PecoMemberCurt,
You have to have libraries in lib directory – ant engine doesn’t use project classpath
Best regards
Curt KingParticipantI’ll try that — but I’m curious why adding the libraries to the Ant configuration’s classpath didn’t work.
Also, if I added the libraries to my project’s build path, aren’t they automatically placed in my /lib directory?
Thanks for your patience — I’m still trying to figure all of this out!
Thanks again for your help,
Curt
Haris PecoMemberI’ll try that — but I’m curious why adding the libraries to the Ant configuration’s classpath didn’t work.
ant doesn’t use classpath out of engine, like eclipse
Also, if I added the libraries to my project’s build path, aren’t they automatically placed in my /lib directory?
no, libraries can be anywhere
Thanks again for your help,
you welcome
raj82MemberI am having same problem as Curt has. I have included all librarires in lib folder but still doent work.
Thank you.
-
AuthorPosts