SOLVED
Great. After I type all this in, I was trying out some other stuff, and found the following.
I have the hibernate-tools.jar in the ant/lib directory.
If I remove that hibernate-tools.jar and add it to the hibernate.cp below, things work right.
Sheesh. I guess that's just my lack of understanding of how ant classloaders work.
Anyways, I figured I would go ahead and post it in case somebody else had this problem.
Summary: When using the hibernatetool ant task, NoClassDefFoundError: org/hibernate/cfg/Configuration exception thrown unless hibernate3.jar is in system level classpath.
Hibernate version: hibernate-3.1 alpha 1, hibernate-tools 3.0 alpha 4a
build.xml
<project name="testBuild" default="testTool" basedir=".">
<path id="hibernate.cp">
<pathelement location="hibernate3.jar"/>
</path>
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="hibernate.cp"
/>
<target name="testTool">
<hibernatetool destdir=".">
<annotationconfiguration/>
<hbm2ddl outputfilename="hbm2ddl.sql"/>
</hibernatetool>
</target>
</project>
Description
I realize that the build is not complete, I was just putting a simple build in to try to narrow down my problem. The build, as shown, throws the Exception mentioned. I have tried changing the taskdef to have a classpath instead of classpathref, and a few other variations of that, to no avail. The only thing that gets me to my next missing jar (LogFactory) is to
export CLASSPATH=hibernate3.jar
from the command line before executing the ant testTool. Also, if I put hibernate3.jar
Full output follows:
> ant -debug -f testbuild.xml
Apache Ant version 1.6.5 compiled on June 2 2005
Buildfile: testbuild.xml
Adding reference: ant.PropertyHelper
Detected Java version: 1.5 in: /opt/devel/jdk1.5.0_02/jre
Detected OS: Linux
Adding reference: ant.ComponentHelper
Setting ro project property: ant.version -> Apache Ant version 1.6.5 compiled on June 2 2005
Setting ro project property: ant.file -> /opt/cvs/build/testbuild.xml
Adding reference: ant.projectHelper
Adding reference: ant.parsing.context
Adding reference: ant.targets
parsing buildfile /opt/cvs/build/testbuild.xml with URI = file:///opt/cvs/build/testbuild.xml
Setting ro project property: ant.project.name -> testBuild
Adding reference: testBuild
Setting ro project property: ant.file.testBuild -> /opt/cvs/build/testbuild.xml
Project base dir set to: /opt/cvs/build
+Target:
Adding reference: hibernate.cp
+Target: testTool
Could not load a dependent class (com/sun/media/jai/codec/FileSeekableStream) for type image
Could not load a dependent class (com/jcraft/jsch/UserInfo) for type sshexec
Could not load a dependent class (com/jcraft/jsch/UserInfo) for type scp
Adding reference: hibernate.cp
Class org.hibernate.tool.ant.HibernateToolTask loaded from parent loader (parentFirst)
+Datatype hibernatetool org.hibernate.tool.ant.HibernateToolTask
Attempting to create object of type org.apache.tools.ant.helper.DefaultExecutor
Adding reference: ant.executor
Build sequence for target(s) `testTool' is [testTool]
Complete build sequence is [testTool, ]
testTool:
BUILD FAILED
java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1225)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Caused by: java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2365)
at java.lang.Class.privateGetPublicMethods(Class.java:2488)
at java.lang.Class.getMethods(Class.java:1406)
at org.apache.tools.ant.IntrospectionHelper.<init>(IntrospectionHelper.java:171)
at org.apache.tools.ant.IntrospectionHelper.getHelper(IntrospectionHelper.java:315)
at org.apache.tools.ant.UnknownElement.handleChildren(UnknownElement.java:318)
at org.apache.tools.ant.UnknownElement.configure(UnknownElement.java:182)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:158)
at org.apache.tools.ant.Task.perform(Task.java:363)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
... 7 more
--- Nested Exception ---
java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2365)
at java.lang.Class.privateGetPublicMethods(Class.java:2488)
at java.lang.Class.getMethods(Class.java:1406)
at org.apache.tools.ant.IntrospectionHelper.<init>(IntrospectionHelper.java:171)
at org.apache.tools.ant.IntrospectionHelper.getHelper(IntrospectionHelper.java:315)
at org.apache.tools.ant.UnknownElement.handleChildren(UnknownElement.java:318)
at org.apache.tools.ant.UnknownElement.configure(UnknownElement.java:182)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:158)
at org.apache.tools.ant.Task.perform(Task.java:363)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
|