Hello there,
I am trying to reverse engineering database and I had put in the ReverseEngineeringStrategy class. I had this problem of classloader cannot locate my hibernate libraries file.
I had done my very best to test using different method to validate the existing of classpath but still fail. Please help me out. I had includes the following code blocks. TQ
--------------------------------------------------------------------------------
Hibernate version: 3.1.0, Hibernate Tools version: 3.1.0 beta1
Mapping documents:
1. Ant task build.xml
Code:
<target name="init">
<!-- source directories -->
<property name="src.dir" value="${basedir}/ems-ear"/>
<property name="src.commonclient.dir" value="${src.dir}/common-client"/>
<property name="src.commonwarclasses.dir" value="${src.dir}/common-war-classes"/>
<property name="src.internalclient.dir" value="${src.dir}/ems-internal-war"/>
<property name="src.externalclient.dir" value="${src.dir}/ems-external-war"/>
<property name="src.entity.dir" value="${src.dir}/entity"/>
<property name="src.backend.dir" value="${src.dir}/backend/core"/>
<property name="src.reversedb.dir" value="${basedir}/reversedb"/>
<property name="lib.dir" value="${basedir}/lib"/>
<!-- destination directories -->
<property name="build.dir" value="${basedir}/build"/>
<property name="build.commonclient.dir" value="${build.dir}/common-client"/>
<property name="build.commonwarclasses.dir" value="${build.dir}/common-war-classes"/>
<property name="build.internalclient.dir" value="${build.dir}/ems-internal-client"/>
<property name="build.externalclient.dir" value="${build.dir}/ems-external-client"/>
<property name="build.entity.dir" value="${build.dir}/entity"/>
<property name="build.backend.dir" value="${build.dir}/backend"/>
<property name="build.reverseorm.dir" value="${build.dir}/reverse-engineer-orm"/>
<property name="build.reversedb.dir" value="${build.dir}/reversedb"/>
<property name="build.deploy.dir" value="${build.dir}/deploy"/>
<!-- The project classpath -->
<path id="project.classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
<include name="**/*.zip"/>
</fileset>
<pathelement location="${build.entity.dir}"/>
</path>
<!--taskdef name="sun-appserv-deploy" classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.DeployTask">
<classpath refid="project.classpath"/>
</taskdef-->
</target>
...
<target name="reversedb" depends="init">
<mkdir dir="${build.reverseorm.dir}"/>
<mkdir dir="${build.reversedb.dir}"/>
<!-- TODO: to fix with property strategy, etc. -->
<javac srcdir="${src.reversedb.dir}" destdir="${build.reversedb.dir}" classpathref="project.classpath" />
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask">
<classpath>
<path refid="project.classpath"/>
</classpath>
</taskdef>
<echo message="Hello World!"/>
<hibernatetool destdir="${build.reverseorm.dir}">
<classpath>
<path refid="project.classpath"/>
<pathelement path="${build.reversedb.dir}"/>
</classpath>
<jdbcconfiguration packagename="gov.mohr.ems" configurationfile="hibernate.cfg.xml" revengfile="hibernate.reveng.xml" reversestrategy="EMSReverseEngineerDatabaseStrategy"/>
<hbm2hbmxml/>
<hbm2java ejb3="false" generics="false"/>
</hibernatetool>
</target>
The target I need to run is "reversedb".
2. The reverse engineer strategy java file
Code:
import org.hibernate.cfg.reveng.DelegatingReverseEngineeringStrategy;
import org.hibernate.cfg.reveng.ReverseEngineeringStrategy;
import org.hibernate.cfg.reveng.TableIdentifier;
/*
* EMSReverseEngineerDatabaseStrategy.java
*
* Created on April 3, 2006, 10:16 AM
*
* To change this template, choose Tools | Options and locate the template under
* the Source Creation and Management node. Right-click the template and choose
* Open. You can then make changes to the template in the Source Editor.
*/
/**
*
* @author david
*/
public class EMSReverseEngineerDatabaseStrategy extends DelegatingReverseEngineeringStrategy{
/* Some constant for conversion naming, refer to SDD10 section 10.4 */
private String packageName = "gov.mohr.ems";
private String entitySuffix = "entity";
private static final String dot = ".";
/** Creates a new instance of EMSReverseEngineerDatabaseStrategy */
public EMSReverseEngineerDatabaseStrategy(ReverseEngineeringStrategy delegate) {
super(delegate);
}
/* This will convert the naming convention of table name to convention used in SDD10 section 10.4 */
public String tableToClassName(TableIdentifier tableIdentifier) {
String[] list = tableIdentifier.getName().split("_", 2);
if (list[0].length() > 1) {
return this.packageName + this.dot + list[0].substring(0, 0) + this.dot + list[0].substring(1) + this.dot + this.entitySuffix + this.dot + list[1];
} else {
return this.packageName + this.dot + list[0] + this.dot + this.entitySuffix + this.dot + list[1];
}
}
}
Full stack trace of any exception that occurs:Code:
Detected Java version: 1.5 in: C:\java\jdk1.5.0_06\jre
Detected OS: Windows XP
parsing buildfile jar:file:/C:/java/jstudio_ent8/ide/ide5/ant/nblib/org-netbeans-modules-ant-browsetask.jar!/org/netbeans/modules/ant/browsetask/antlib.xml with URI = jar:file:/C:/java/jstudio_ent8/ide/ide5/ant/nblib/org-netbeans-modules-ant-browsetask.jar!/org/netbeans/modules/ant/browsetask/antlib.xml
parsing buildfile jar:file:/C:/java/jstudio_ent8/ide/ide5/ant/nblib/org-netbeans-modules-ant-browsetask.jar!/org/netbeans/modules/ant/browsetask/antlib.xml with URI = jar:file:/C:/java/jstudio_ent8/ide/ide5/ant/nblib/org-netbeans-modules-ant-browsetask.jar!/org/netbeans/modules/ant/browsetask/antlib.xml
parsing buildfile jar:file:/C:/java/jstudio_ent8/ide/ide5/ant/nblib/org-netbeans-modules-debugger-jpda-ant.jar!/org/netbeans/modules/debugger/jpda/ant/antlib.xml with URI = jar:file:/C:/java/jstudio_ent8/ide/ide5/ant/nblib/org-netbeans-modules-debugger-jpda-ant.jar!/org/netbeans/modules/debugger/jpda/ant/antlib.xml
parsing buildfile jar:file:/C:/java/jstudio_ent8/ide/ide5/ant/nblib/org-netbeans-modules-debugger-jpda-ant.jar!/org/netbeans/modules/debugger/jpda/ant/antlib.xml with URI = jar:file:/C:/java/jstudio_ent8/ide/ide5/ant/nblib/org-netbeans-modules-debugger-jpda-ant.jar!/org/netbeans/modules/debugger/jpda/ant/antlib.xml
parsing buildfile jar:file:/C:/java/jstudio_ent8/ide/enterprise1/ant/nblib/org-netbeans-modules-j2ee-ant.jar!/org/netbeans/modules/j2ee/ant/antlib.xml with URI = jar:file:/C:/java/jstudio_ent8/ide/enterprise1/ant/nblib/org-netbeans-modules-j2ee-ant.jar!/org/netbeans/modules/j2ee/ant/antlib.xml
parsing buildfile jar:file:/C:/java/jstudio_ent8/ide/enterprise1/ant/nblib/org-netbeans-modules-j2ee-ant.jar!/org/netbeans/modules/j2ee/ant/antlib.xml with URI = jar:file:/C:/java/jstudio_ent8/ide/enterprise1/ant/nblib/org-netbeans-modules-j2ee-ant.jar!/org/netbeans/modules/j2ee/ant/antlib.xml
parsing buildfile jar:file:/C:/java/jstudio_ent8/ide/enterprise1/ant/nblib/org-netbeans-modules-j2ee-sun-ide.jar!/org/netbeans/modules/j2ee/sun/ide/antlib.xml with URI = jar:file:/C:/java/jstudio_ent8/ide/enterprise1/ant/nblib/org-netbeans-modules-j2ee-sun-ide.jar!/org/netbeans/modules/j2ee/sun/ide/antlib.xml
parsing buildfile jar:file:/C:/java/jstudio_ent8/ide/enterprise1/ant/nblib/org-netbeans-modules-j2ee-sun-ide.jar!/org/netbeans/modules/j2ee/sun/ide/antlib.xml with URI = jar:file:/C:/java/jstudio_ent8/ide/enterprise1/ant/nblib/org-netbeans-modules-j2ee-sun-ide.jar!/org/netbeans/modules/j2ee/sun/ide/antlib.xml
parsing buildfile C:\ems\src\build.xml with URI = file:///C:/ems/src/build.xml
Project base dir set to: C:\ems\src
Build sequence for target `reversedb' is [init, reversedb]
Complete build sequence is [init, reversedb, mkdir, compile-server, undeploy-local, compile-entity, compile-common-client, compile-internal, compile-external, compile-client, compile-all, jar, deploy-local, javadoc, clean, ]
init:
reversedb:
EMSReverseEngineerDatabaseStrategy.java omitted as EMSReverseEngineerDatabaseStrategy.class is up to date.
Hello World!
Executing Hibernate Tool with a JDBC Configuration (for reverse engineering)
1. task: cfg2hbm (Generates a set of hbm.xml files)
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
java.lang.NoSuchMethodError: org.hibernate.mapping.Table.qualify(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;C)Ljava/lang/String;
at org.apache.tools.ant.Project.executeTarget(Project.java:1223)
at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:234)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:242)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:125)
Caused by: java.lang.NoSuchMethodError: org.hibernate.mapping.Table.qualify(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;C)Ljava/lang/String;
at org.hibernate.cfg.reveng.JDBCReader.processBasicColumns(JDBCReader.java:413)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:56)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:731)
at org.hibernate.cfg.JDBCBinder.readDatabaseSchema(JDBCBinder.java:122)
at org.hibernate.cfg.JDBCBinder.readFromDatabase(JDBCBinder.java:88)
at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:40)
at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:73)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:180)
at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:196)
at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:90)
at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:38)
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.executeTarget(Project.java:1214)
... 4 more
--- Nested Exception ---
java.lang.NoSuchMethodError: org.hibernate.mapping.Table.qualify(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;C)Ljava/lang/String;
at org.hibernate.cfg.reveng.JDBCReader.processBasicColumns(JDBCReader.java:413)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:56)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:731)
at org.hibernate.cfg.JDBCBinder.readDatabaseSchema(JDBCBinder.java:122)
at org.hibernate.cfg.JDBCBinder.readFromDatabase(JDBCBinder.java:88)
at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:40)
at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:73)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:180)
at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:196)
at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:90)
at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:38)
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.executeTarget(Project.java:1214)
at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:234)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:242)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:125)
BUILD FAILED (total time: 4 seconds)
Name and version of the database you are using:Oracle 10g
hibernate.cfg.xmlCode:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@10.2.1.191:1521:EMSC</property>
<property name="connection.username">hibernate</property>
<property name="connection.password">hibernate</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
</session-factory>
</hibernate-configuration>
hibernate.reveng.xmlCode:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
<hibernate-reverse-engineering>
<!--type-mapping>
<sql-type jdbc-type="NUMERIC" length="1" hibernate-type="boolean" />
</type-mapping-->
</hibernate-reverse-engineering>
------------------------------------------------------------------
Please help.