Hi,
I tried to use HibernateToolTask to write the schema update script to an external file but I got some errors.
Note: I'm using annotations.
Here is the ant task I wrote:
Code:
<path id="hibernateTool.classpath">
<fileset dir="${tomcat.home}/webapps/4s/WEB-INF/lib" includes="hibernate3.jar"/>
<fileset dir="${tomcat.home}/webapps/4s/WEB-INF/lib" includes="hibernate-tools*.jar"/>
<fileset dir="${tomcat.home}/webapps/4s/WEB-INF/lib" includes="mysql-connector-java*.jar"/>
<fileset dir="${tomcat.home}/webapps/4s/WEB-INF/lib" includes="velocity*.jar"/>
<fileset dir="${tomcat.home}/webapps/4s/WEB-INF/lib" includes="jtidy*.jar"/>
<fileset dir="${tomcat.home}/webapps/4s/WEB-INF/lib" includes="commons*.jar"/>
<fileset dir="${tomcat.home}/webapps/4s/WEB-INF/lib" includes="hibernate-annotations.jar"/>
<fileset dir="${tomcat.home}/webapps/4s/WEB-INF/lib" includes="dom4j*.jar"/>
</path>
<target name="hibernatetool">
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="hibernateTool.classpath"/>
<hibernatetool destdir="${tomcat.home}/webapps/4s/ant">
<classpath> <!-- a classpath is optional, but needed for exporters that require access to domain classes etc. -->
<path location="${tomcat.home}/webapps/4s/src/"/>
</classpath>
<annotationconfiguration configurationfile="dfdf.cfg.xml">
<fileset dir="${tomcat.home}/webapps/4s/src/" id="id">
<include name="**/*.java"/>
</fileset>
</annotationconfiguration>
<hbm2ddl update="true"
outputfilename="schema.sql"
delimiter = ";"/>
</hibernatetool>
</target>
Here is the error I get:Code:
/home/smagied/dev/eclipse/production/4s/ant/ant.xml:76: Problems in creating a AnnotationConfiguration. Have you remembered to add it to the classpath ?
at org.hibernate.tool.ant.AnnotationConfigurationTask.createConfiguration(AnnotationConfigurationTask.java:30)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:54)
at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:180)
at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:35)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:144)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
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.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:416)
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:138)
Caused by: java.lang.NoSuchMethodError: org.hibernate.util.ReflectHelper.classForName(Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Class;
at org.hibernate.tool.ant.AnnotationConfigurationTask.createConfiguration(AnnotationConfigurationTask.java:26)
... 14 more
--- Nested Exception ---
java.lang.NoSuchMethodError: org.hibernate.util.ReflectHelper.classForName(Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Class;
at org.hibernate.tool.ant.AnnotationConfigurationTask.createConfiguration(AnnotationConfigurationTask.java:26)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:54)
at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:180)
at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:35)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:144)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
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.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:416)
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:138)
I would like to know, from where could I download the source code of hibernate-tools.jar as it's not included in the jar and I couldn't find it on CVS.
Thanks in advance.