I'm trying to reverse engineer hbm.xml files, pojos and daos from a SQLServer database. I've been wrestling with it all day, but now I'm stuck and I don't seem to be having much luck researching my own solution.
Here's my build.xml file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<project name="HibernateAnt" basedir=".">
<property name="src.dir" location="src" />
<property name="lib.dir" location="WebContent/WEB-INF/lib" />
<property name="bin.dir" location="build/hibernate" />
<!--
<path id="project.class.path">
<path>
<pathelement location="${lib.dir}/hibernate3.jar" />
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset >
<pathelement path="${bin.dir}" />
</path>
</path>
-->
<!-- Compile the java source of the project -->
<target name="compile" description="Compiles all Java classes">
<javac srcdir="${src.dir}" destdir="${bin.dir}" debug="on" optimize="off" deprecation="on">
<classpath refid="project.class.path" />
</javac>
</target>
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask">
<classpath>
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
</classpath>
</taskdef>
<target name="gen_hibernate"
description="generate hibernate classes">
<hibernatetool>
<jdbcconfiguration
configurationfile="src/config/hibernate.cfg.xml"
packagename="com.openversion.bus"
detectmanytomany="true"
/>
<hbm2hbmxml destdir="src" />
<hbm2java destdir="src" />
</hibernatetool>
</target>
</project>
and my hibernate.cfg.xml file:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE
hibernate-configuration
SYSTEM
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"
>
<hibernate-configuration>
<session-factory>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:jtds:sqlserver://localhost/MMOConnection</property>
<property name="hibernate.connection.username">reveng</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.bytecode.use_reflection_optimizer">true</property>
<property name="hibernate.connection.pool_size">0</property>
<mapping jar="hibernate3.jar" />
<!-- <mapping package="uk.co.mmoconnection.view.service.dao.hbmxml"/> -->
</session-factory>
</hibernate-configuration>
after running the ant task i get:
Code:
Apache Ant version 1.7.1 compiled on June 27 2008
Buildfile: G:\Users\Adam\workspace\MMOConnection\build.xml
parsing buildfile G:\Users\Adam\workspace\MMOConnection\build.xml with URI = file:/G:/Users/Adam/workspace/MMOConnection/build.xml
Project base dir set to: G:\Users\Adam\workspace\MMOConnection
[antlib:org.apache.tools.ant] Could not load definitions from resource org/apache/tools/ant/antlib.xml. It could not be found.
Arguments: -verbose -Dorg.eclipse.ant.core.ANT_PROCESS_ID=1274812685161
Build sequence for target(s) `gen_hibernate' is [gen_hibernate]
Complete build sequence is [gen_hibernate, compile, ]
gen_hibernate:
[hibernatetool] Executing Hibernate Tool with a JDBC Configuration (for reverse engineering)
[hibernatetool] 1. task: hbm2hbmxml (Generates a set of hbm.xml files)
[hibernatetool] 94 [Thread-67] INFO org.hibernate.cfg.Environment - Hibernate 3.5.1-Final
[hibernatetool] 100 [Thread-67] INFO org.hibernate.cfg.Environment - hibernate.properties not found
[hibernatetool] 110 [Thread-67] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
[hibernatetool] 136 [Thread-67] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
[hibernatetool] 716 [Thread-67] INFO org.hibernate.cfg.Configuration - configuring from file: hibernate.cfg.xml
[hibernatetool] 958 [Thread-67] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
[hibernatetool] 1091 [Thread-67] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
[hibernatetool] 1092 [Thread-67] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 0
[hibernatetool] 1092 [Thread-67] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
[hibernatetool] 1097 [Thread-67] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: net.sourceforge.jtds.jdbc.Driver at URL: jdbc:jtds:sqlserver://localhost/MMOConnection
[hibernatetool] 1098 [Thread-67] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=reveng, password=****}
[hibernatetool] 1357 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - RDBMS: Microsoft SQL Server, version: 10.00.2531
[hibernatetool] 1357 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: jTDS Type 4 JDBC Driver for MS SQL Server and Sybase, version: 1.2.5
[hibernatetool] 1545 [Thread-67] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.SQLServerDialect
[hibernatetool] 1801 [Thread-67] INFO org.hibernate.engine.jdbc.JdbcSupportLoader - Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
[hibernatetool] 1815 [Thread-67] INFO org.hibernate.transaction.TransactionFactoryFactory - Using default transaction strategy (direct JDBC transactions)
[hibernatetool] 1831 [Thread-67] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
[hibernatetool] 1831 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
[hibernatetool] 1831 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
[hibernatetool] 1835 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
[hibernatetool] 1835 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled
[hibernatetool] 1835 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
[hibernatetool] 1839 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
[hibernatetool] 1839 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
[hibernatetool] 1839 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
[hibernatetool] 1839 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
[hibernatetool] 1839 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
[hibernatetool] 1855 [Thread-67] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
[hibernatetool] 1856 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
[hibernatetool] 1856 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
[hibernatetool] 1856 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
[hibernatetool] 1856 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
[hibernatetool] 1856 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
[hibernatetool] 1856 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
[hibernatetool] 1856 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
[hibernatetool] 1896 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
[hibernatetool] 1896 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
[hibernatetool] 1897 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
[hibernatetool] 1897 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled
[hibernatetool] 1897 [Thread-67] INFO org.hibernate.cfg.SettingsFactory - Check Nullability in Core (should be disabled when Bean Validation is on): enabled
[hibernatetool] 2115 [Thread-67] INFO org.hibernate.connection.DriverManagerConnectionProvider - cleaning up connection pool: jdbc:jtds:sqlserver://localhost/MMOConnection
BUILD FAILED
G:\Users\Adam\workspace\MMOConnection\build.xml:36: java.lang.IncompatibleClassChangeError: Found interface org.hibernate.cfg.Mappings, but class was expected
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116)
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.eclipse.ant.internal.core.ant.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:662)
at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:495)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.ant.core.AntRunner.run(AntRunner.java:378)
at org.eclipse.ant.internal.ui.launchConfigurations.AntLaunchDelegate$1.run(AntLaunchDelegate.java:258)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IncompatibleClassChangeError: Found interface org.hibernate.cfg.Mappings, but class was expected
at org.hibernate.cfg.reveng.MappingsDatabaseCollector.getTable(MappingsDatabaseCollector.java:25)
at org.hibernate.cfg.reveng.JDBCReader.processTables(JDBCReader.java:535)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:74)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:860)
at org.hibernate.cfg.JDBCBinder.readDatabaseSchema(JDBCBinder.java:121)
at org.hibernate.cfg.JDBCBinder.readFromDatabase(JDBCBinder.java:94)
at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:42)
at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:83)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)
at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:318)
at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:94)
at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
... 17 more
--- Nested Exception ---
java.lang.IncompatibleClassChangeError: Found interface org.hibernate.cfg.Mappings, but class was expected
at org.hibernate.cfg.reveng.MappingsDatabaseCollector.getTable(MappingsDatabaseCollector.java:25)
at org.hibernate.cfg.reveng.JDBCReader.processTables(JDBCReader.java:535)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:74)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:860)
at org.hibernate.cfg.JDBCBinder.readDatabaseSchema(JDBCBinder.java:121)
at org.hibernate.cfg.JDBCBinder.readFromDatabase(JDBCBinder.java:94)
at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:42)
at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:83)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)
at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:318)
at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:94)
at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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.eclipse.ant.internal.core.ant.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:662)
at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:495)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.ant.core.AntRunner.run(AntRunner.java:378)
at org.eclipse.ant.internal.ui.launchConfigurations.AntLaunchDelegate$1.run(AntLaunchDelegate.java:258)
at java.lang.Thread.run(Unknown Source)
Total time: 2 seconds
here's a list of the jars i have included in the project:
Code:
commons-logging-1.0.4.jar
dom4j-1.5.2.jar
hibernate3.jar
hibernate-core-3.5.1-Final.jar
hibernate-tools-3.2.4.GA.jar
jtds-1.2.5.jar
slf4j-api-1.6.0.jar
slf4j-simple-1.6.0.jar
sqljdbc.jar
I'm not really sure what could cause a "Found interface org.hibernate.cfg.Mappings, but class was expected" error. I suspect I'm using a wrong jar file, but i'd appriciate any help, thanks!