Hi I am trying to use the schema export tool to create the ddl scripts for my MYSQL Database. However each time I run my Ant file I get the following stack trace:
Code:
schemaexport:
[schemaexport] (cfg.Environment 462 ) Hibernate 2.1.4
[schemaexport] (cfg.Environment 496 ) loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=com.mysql.jdbc.Driver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=net.sf.ehcache.hibernate.Provider, hibernate.cache.use_query_cache=true, hibernate.max_fetch_depth=1, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.jdbc.batch_size=0,hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.username=root, hibernate.cache.region_prefix=hibernate.test, hibernate.connection.url=jdbc:mysql:///test, hibernate.show_sql=true, hibernate.connection.password=, hibernate.connection.pool_size=1}
[schemaexport] (cfg.Environment 521 ) using java.io streamsto persist binary types
[schemaexport] (cfg.Environment 522 ) using CGLIB reflection optimizer
[schemaexport] (cfg.Configuration 166 ) Mapping file: C:\java\classes\medical\busobj\Activation.hbm.xml
[schemaexport] (cfg.Configuration 252 ) Could not compile the mapping document
[schemaexport] net.sf.hibernate.MappingException: persistent class [medical.busobj.Activation] not found
[schemaexport] at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:84)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1243)
[schemaexport] at net.sf.hibernate.cfg.Configuration.add(Configuration.java:249)
[schemaexport] at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:171)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExportTask.java:195)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:135)
[schemaexport] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:306)
[schemaexport] at org.apache.tools.ant.Task.perform(Task.java:401)
[schemaexport] at org.apache.tools.ant.Target.execute(Target.java:338)
[schemaexport] at org.apache.tools.ant.Target.performTasks(Target.java:365)
[schemaexport] at org.apache.tools.ant.Project.executeTarget(Project.java:1237)
[schemaexport] at org.apache.tools.ant.Project.executeTargets(Project.java:1094)
[schemaexport] at org.apache.tools.ant.Main.runBuild(Main.java:669)
[schemaexport] at org.apache.tools.ant.Main.startAnt(Main.java:220)
[schemaexport] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:215)
[schemaexport] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:90)
[schemaexport] Caused by: java.lang.ClassNotFoundException: medical.busobj.Activation
[schemaexport] at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
[schemaexport] at java.security.AccessController.doPrivileged(Native Method)
[schemaexport] at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
[schemaexport] at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
[schemaexport] at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
[schemaexport] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
[schemaexport] at java.lang.Class.forName0(Native Method)
[schemaexport] at java.lang.Class.forName(Class.java:141)
[schemaexport] at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:102)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:81)
[schemaexport] ... 16 more
[schemaexport] (cfg.Configuration 175 ) Could not configure datastore from file: C:\java\classes\medical\busobj\Activation.hbm.xml
[schemaexport] net.sf.hibernate.MappingException: persistent class [medical.busobj.Activation] not found
[schemaexport] at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:84)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1243)
[schemaexport] at net.sf.hibernate.cfg.Configuration.add(Configuration.java:249)
[schemaexport] at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:171)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExportTask.java:195)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:135)
[schemaexport] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:306)
[schemaexport] at org.apache.tools.ant.Task.perform(Task.java:401)
[schemaexport] at org.apache.tools.ant.Target.execute(Target.java:338)
[schemaexport] at org.apache.tools.ant.Target.performTasks(Target.java:365)
[schemaexport] at org.apache.tools.ant.Project.executeTarget(Project.java:1237)
[schemaexport] at org.apache.tools.ant.Project.executeTargets(Project.java:1094)
[schemaexport] at org.apache.tools.ant.Main.runBuild(Main.java:669)
[schemaexport] at org.apache.tools.ant.Main.startAnt(Main.java:220)
[schemaexport] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:215)
[schemaexport] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:90)
[schemaexport] Caused by: java.lang.ClassNotFoundException: medical.busobj.Activation
[schemaexport] at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
[schemaexport] at java.security.AccessController.doPrivileged(Native Method)
[schemaexport] at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
[schemaexport] at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
[schemaexport] at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
[schemaexport] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
[schemaexport] at java.lang.Class.forName0(Native Method)
[schemaexport] at java.lang.Class.forName(Class.java:141)
[schemaexport] at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:102)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:81)
[schemaexport]
Now I get that it cant for some reason find the class files but I dont know why when the files are there and compiled.
The build task I am using is as below:
Code:
<target name="schemaexport">
<taskdef name="schemaexport"
classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
classpathref="project.class.path"/>
<schemaexport
properties="hibernate.properties"
quiet="no"
text="no"
drop="no"
delimiter=";"
output="schema-export.sql">
<fileset dir="classes">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaexport>
</target>
Directory structure is like below:
Code:
classes.dir
medical.dir
busobj.dir (this is where the class files go along with copys of the mapping files)
lib.dir
src.dir
medical.dir
busobj.dir (this is where the source files and mapping files are located)
build.xml
hibernate.properties
Any help provided woudl be much appreciated.