I try to generate a schema.ddl from the entity-pojos using Hibernate 4.1.
Hibernate-Libraries including javaee-api-6.0.jar are in WEB-INF/lib. (Project runs on JBoss 7.1.1).
I dont want to use hibernate.hbm2ddl.auto for automatic schema generation.
So I have the following ant-target:
<!-- language: xml -->
<target name="ddl-generation"
description="Export schema to DDL file">
<taskdef name="schemaexport"
classname="org.hibernate.tool.hbm2ddl.SchemaExportTask">
<classpath>
<fileset dir="WebContent/WEB-INF/lib">
<include name="*.jar" />
</fileset>
</classpath>
</taskdef>
<schemaexport
properties="${basedir}/src/META-INF/hibernate.properties"
quiet="no"
text="no"
drop="no"
delimiter=";"
output="${basedir}/schema-export.sql" />
</target>
But when I execute it, it fails with following error:
java.lang.ClassNotFoundException: org.jboss.logging.BasicLogger
at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1361)
at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1311)
at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1064)
I can copy jboss-logging-3.1.0.GA.jar to the classpath of the ant-target, but then it fails, because javaee-api-6.0.jar is only for compiling:
java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/transaction/SystemException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
What can I do to solve this?
Copy all Jboss-Jars?!
How does anyone generate a DDL from JPA-Pojos with Hibernate 4?
It seems to work better with Hibernate3.
You may find this blog post useful http://doingenterprise.blogspot.com/2012/05/schema-generation-with-hibernate-4-jpa.html It describes the process of generating ddl script from JPA 2.0 entities. Though it uses Maven as an example it can be easily adopted to Ant as it just runs a class with a main method. You just need to get the right dependencies. This list should hopefully cover all of them: