• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

schemaexport Ant task

 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am relatively new to Hibernate - I've been trying to get the <schemaexport> Ant task to work but to no avail (as per section 15.1.4 of the manual). Specifically, the task looks for my .class file(s) of the entities that have been mapped. If I jar up the .class files that can't be found (java.lang.ClassNotFoundException), then copy that jar to $ANT_HOME/lib, I have no problem; but clearly, this is not a correct approach.

I have created an isolated case (as a jar/zip file) to help demonstrate my dilemma. It contains the following files:
src/com/foo/Bar.java - an example entity being mapped
build.xml - An Ant build file that fails when I attempt to use the <schemaexport> task
hibernate.properties - A properties file for the <schemaexport> task
Manifest.mf - irrelevant
stderr.txt - The standard error output after executing 'ant -v'
stdout.txt - The standard out output after executing 'ant -v'
The test case can be downloaded from http://www.xdweb.net/~dibblego/miscellaneous/other/test.jar (5045 bytes - unbuilt)
or
http://www.xdweb.net/~dibblego/miscellaneous/other/test-built.jar (7426 bytes - built, but, of course, build fails)

The following is some information which may or may not be relevant:
Using Windows 2003 Enterprise Edition
Using Apache Ant 1.6.1 (February 12 2004)
Using Sun J2SE SDK 1.4.2_04-b05
Using Hibernate 2.1.6
hibernate2.jar and it's dependencies are in $ANT_HOME/lib

To summarise the output of the Ant build, I am receiving a java.lang.ClassNotFoundException because of
C:\test\build.xml:42: Schema text failed: net.sf.hibernate.MappingException: persistent class [com.foo.Bar] not found


Any assistance or suggestions to resolve this issue are most appreciated.
[ September 23, 2004: Message edited by: Tony Morris ]
 
Rashmi Goyal
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The directory where java class file resides, which are generated from the hibernate mapping files you have created is not included in the classpath for schemaexport target in your build file.

generally we put all class files in hibernate\build directory.
 
Jukka Uusisalo
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I think this may be classloading issue because hibernate.jar is in ANT_HOME/lib directory but your persistent class is not in same class-
loader. Propably hibernate requires they should be in same classloader.

I have project class path definition in my build.xml


and then schemaexport def is

and hibernate.jar is in project lib directory.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic