-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: ant task - NoClassDefFoundError
PostPosted: Sat May 02, 2009 4:47 am 
Newbie

Joined: Sat May 02, 2009 3:39 am
Posts: 2
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


Top
 Profile  
 
 Post subject: Re: ant task - NoClassDefFoundError
PostPosted: Tue May 05, 2009 7:13 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
This is using maven which i know very little about. Have you tried using basic ant instead ?

Looks like dom4j is not on the classpath.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: ant task - NoClassDefFoundError
PostPosted: Sat May 09, 2009 1:19 am 
Newbie

Joined: Sat May 02, 2009 3:39 am
Posts: 2
The same actually happens (same errors as in my previous post) when I do not use maven and copy the libs manually on my classpath. A print out of the classpath gives me:

print-classpath:
[echo] d:\working\Programming\projectcontrol\TimeTracker\build;d:\working\Programming\projectcontrol\TimeTracker\sr
c;d:\working\Programming\projectcontrol\TimeTracker\lib;d:\working\Programming\projectcontrol\TimeTracker\lib\antlr-2.7.
6.jar;d:\working\Programming\projectcontrol\TimeTracker\lib\bsh-2.0b1.jar;d:\working\Programming\projectcontrol\TimeTrac
ker\lib\commons-collections-3.1.jar;d:\working\Programming\projectcontrol\TimeTracker\lib\commons-logging-1.1.1.jar;d:\w
orking\Programming\projectcontrol\TimeTracker\lib\dom4j-1.6.1.jar;d:\working\Programming\projectcontrol\TimeTracker\lib\
freemarker.jar;d:\working\Programming\projectcontrol\TimeTracker\lib\gwt-dev-windows.jar;d:\working\Programming\projectc
ontrol\TimeTracker\lib\gwt-incubator_1-5_Dec_28.jar;d:\working\Programming\projectcontrol\TimeTracker\lib\gwt-user.jar;d
:\working\Programming\projectcontrol\TimeTracker\lib\gwt-widgets-0.2.0.jar;d:\working\Programming\projectcontrol\TimeTra
cker\lib\hibernate-tools.jar;d:\working\Programming\projectcontrol\TimeTracker\lib\hibernate3.jar;d:\working\Programming
\projectcontrol\TimeTracker\lib\javassist-3.4.GA.jar;d:\working\Programming\projectcontrol\TimeTracker\lib\jta-1.1.jar;d
:\working\Programming\projectcontrol\TimeTracker\lib\jtidy-r8-20060801.jar;d:\working\Programming\projectcontrol\TimeTra
cker\lib\mysql-connector-java-5.1.7-bin.jar;d:\working\Programming\projectcontrol\TimeTracker\lib\slf4j-api-1.5.2.jar;d:
\working\Programming\projectcontrol\TimeTracker\lib\slf4j-nop-1.5.2.jar

Thus dom4j is also on the classpath.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.