I am trying to make the following ant script from the book Harnessing Hibernate work and end up with the below posted errors.
<?xml version="1.0"?> <project name="Harnessing Hibernate 3 (Developer's Notebook Second Edition default="db" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<!-- Set up properties containing important project directories --> <property name="source.root" value="src"/> <property name="class.root" value="classes"/> <property name="data.dir" value="data"/>
<artifact:dependencies pathId="dependency.class.path"> <dependency groupId="hsqldb" artifactId="hsqldb" version="1.8.0.7"/> <dependency groupId="org.hibernate" artifactId="hibernate" version="3.2.5.ga"> <exclusion groupId="javax.transaction" artifactId="jta"/> </dependency> <dependency groupId="org.hibernate" artifactId="hibernate-tools" version="3.2.0.beta9a"/> <dependency groupId="org.apache.geronimo.specs" artifactId="geronimo-jta_1.1_spec" version="1.1"/> <dependency groupId="log4j" artifactId="log4j" version="1.2.14"/> </artifact:dependencies>
<!-- Set up the class path for compilation and execution --> <path id="project.class.path"> <!-- Include our own classes, of course --> <pathelement location="${class.root}" /> <!-- Add the dependencies classpath --> <path refid="dependency.class.path"/> </path>
<!-- Teach Ant how to use the Hibernate Tools --> <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="project.class.path"/>
<target name="db" description="Runs HSQLDB database management UI against the database file--use when application is not running"> <java classname="org.hsqldb.util.DatabaseManager" fork="yes"> <classpath refid="project.class.path"/> <arg value="-driver"/> <arg value="org.hsqldb.jdbcDriver"/> <arg value="-url"/> <arg value="jdbc:hsqldb:${data.dir}/music"/> <arg value="-user"/> <arg value="sa"/> </java> </target>
<!-- Generate the java code for all mapping files in our source tree --> <target name="codegen" depends="prepare" description="Generate Java source from the O/R mapping files"> <hibernatetool destdir="${source.root}"> <configuration> <fileset dir="${source.root}"> <include name="**/*.xml"/> </fileset> </configuration> <hbm2java/> </hibernatetool> </target>
<!-- Create our runtime subdirectories and copy resources into them --> <target name="prepare" description="Sets up build structures"> <mkdir dir="${class.root}"/>
<!-- Copy our property files and O/R mappings for use at runtime --> <copy todir="${class.root}" > <fileset dir="${source.root}" > <include name="**/*.properties"/> <include name="**/*.hbm.xml"/> </fileset> </copy> </target>
<!-- Generate the schemas for all mapping files in our class tree --> <target name="schema" depends="prepare" description="Generate DB schema from the O/R mapping files">
<hibernatetool destdir="${source.root}"> <configuration> <fileset dir="${class.root}"> <include name="**/*.hbm.xml"/> </fileset> </configuration> <hbm2ddl drop="yes" /> </hibernatetool> </target>
</project>
$ ant codegen Buildfile: build.xml
prepare:
codegen: [hibernatetool] Executing Hibernate Tool with a Standard Configuration [hibernatetool] 1. task: hbm2java (Generates a set of .java files)
BUILD FAILED java.lang.NoClassDefFoundError: org/dom4j/DocumentException at org.hibernate.tool.ant.ConfigurationTask.createConfiguration(ConfigurationTask.java:62) at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:54) at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:299) at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:315) at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:94) at org.hibernate.tool.ant.Hbm2JavaExporterTask.configureExporter(Hbm2JavaExporterTask.java:34) at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39) at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:183) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:357) at org.apache.tools.ant.Target.performTasks(Target.java:385) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) at org.apache.tools.ant.Project.executeTarget(Project.java:1306) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1189) at org.apache.tools.ant.Main.runBuild(Main.java:758) at org.apache.tools.ant.Main.startAnt(Main.java:217) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104) Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) ... 25 more
Total time: 0 seconds
HartmannT@ctw-bi-nb-017 /cygdrive/d/working/Reading/E-Books/Harnessing-Hibernate/examples/ch02 $ ant schema Buildfile: build.xml
prepare:
schema: [hibernatetool] Executing Hibernate Tool with a Standard Configuration [hibernatetool] 1. task: hbm2ddl (Generates database schema)
BUILD FAILED java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory at org.hibernate.tool.hbm2ddl.SchemaExport.<clinit>(SchemaExport.java:70) at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45) at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:183) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:357) at org.apache.tools.ant.Target.performTasks(Target.java:385) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) at org.apache.tools.ant.Project.executeTarget(Project.java:1306) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1189) at org.apache.tools.ant.Main.runBuild(Main.java:758) at org.apache.tools.ant.Main.startAnt(Main.java:217) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104) Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) ... 20 more
Total time: 0 seconds
At least the dom4jxxx.jar is on the classpath: $ ant print-classpath Buildfile: build.xml
print-classpath: [echo] C:\Users\hartmannt\.m2\repository\hsqldb\hsqldb\1.8.0.7\hsqldb \org\hibernate\hibernate\3.2.5.ga\hibernate-3.2.5.ga.jar;C:\Users\hartmann ehcache-1.2.3.jar;C:\Users\hartmannt\.m2\repository\commons-logging\common sers\hartmannt\.m2\repository\commons-collections\commons-collections\2.1. annt\.m2\repository\asm\asm-attrs\1.5.3\asm-attrs-1.5.3.jar;C:\Users\hartm 6.1.jar;C:\Users\hartmannt\.m2\repository\antlr\antlr\2.7.6\antlr-2.7.6.ja b\2.1_3\cglib-2.1_3.jar;C:\Users\hartmannt\.m2\repository\asm\asm\1.5.3\as org\hibernate\hibernate-tools\3.2.0.beta9a\hibernate-tools-3.2.0.beta9a.ja \freemarker\2.3.4\freemarker-2.3.4.jar;C:\Users\hartmannt\.m2\repository\o 01.jar;C:\Users\hartmannt\.m2\repository\org\apache\geronimo\specs\geronim ar;C:\Users\hartmannt\.m2\repository\log4j\log4j\1.2.14\log4j-1.2.14.jar
If I add slf4j:
<dependency groupId="org.slf4j" artifactId="slf4j-api" version="1.5.6"/> <dependency groupId="org.slf4j" artifactId="slf4j-log4j12" version="1.5.6"/>
I end up with this classpath: [echo] C:\Users\hartmannt\.m2\repository\hsqldb\hsqldb\1.8.0.7\hsqldb-1.8.0.7.jar;C:\Users\hartmannt\.m2\repository \hibernate\hibernate\3.2.5.ga\hibernate-3.2.5.ga.jar;C:\Users\hartmannt\.m2\repository\net\sf\ehcache\ehcache\1.2.3\ che-1.2.3.jar;C:\Users\hartmannt\.m2\repository\commons-logging\commons-logging\1.0.4\commons-logging-1.0.4.jar;C:\U \hartmannt\.m2\repository\commons-collections\commons-collections\2.1.1\commons-collections-2.1.1.jar;C:\Users\hartm \.m2\repository\asm\asm-attrs\1.5.3\asm-attrs-1.5.3.jar;C:\Users\hartmannt\.m2\repository\dom4j\dom4j\1.6.1\dom4j-1. jar;C:\Users\hartmannt\.m2\repository\antlr\antlr\2.7.6\antlr-2.7.6.jar;C:\Users\hartmannt\.m2\repository\cglib\cgli 1_3\cglib-2.1_3.jar;C:\Users\hartmannt\.m2\repository\asm\asm\1.5.3\asm-1.5.3.jar;C:\Users\hartmannt\.m2\repository\ hibernate\hibernate-tools\3.2.0.beta9a\hibernate-tools-3.2.0.beta9a.jar;C:\Users\hartmannt\.m2\repository\freemarker emarker\2.3.4\freemarker-2.3.4.jar;C:\Users\hartmannt\.m2\repository\org\hibernate\jtidy\r8-20060801\jtidy-r8-200608 ar;C:\Users\hartmannt\.m2\repository\org\apache\geronimo\specs\geronimo-jta_1.1_spec\1.1\geronimo-jta_1.1_spec-1.1.j :\Users\hartmannt\.m2\repository\log4j\log4j\1.2.14\log4j-1.2.14.jar;C:\Users\hartmannt\.m2\repository\org\slf4j\slf pi\1.5.6\slf4j-api-1.5.6.jar;C:\Users\hartmannt\.m2\repository\org\slf4j\slf4j-log4j12\1.5.6\slf4j-log4j12-1.5.6.jar
I get the same result.
Any help is greatly appreciated.
Thanks, Timo
|