-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Reverse Engineer Database Problem
PostPosted: Mon Apr 03, 2006 9:59 pm 
Beginner
Beginner

Joined: Fri May 21, 2004 5:22 am
Posts: 24
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.xml

Code:
<?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.xml

Code:
<?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.


Top
 Profile  
 
 Post subject: Re: Reverse Engineer Database Problem
PostPosted: Tue Apr 04, 2006 2:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
gigsvoo wrote:

Hibernate version: 3.1.0, Hibernate Tools version: 3.1.0 beta1


start by using the latest release.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 04, 2006 11:17 am 
Regular
Regular

Joined: Wed Mar 15, 2006 1:48 pm
Posts: 91
Can you share how you can specify tables to be reverse engineered? In my case I needn't use Hibernate tool to parse whole schema, just the specific tables. I don't know which ant task can handle the input of table names. Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 04, 2006 12:57 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
for that use a reveng.xml file.

Description on what it can do:
http://www.hibernate.org/hib_docs/tools ... ngineering

and how to use it in ant:
http://www.hibernate.org/hib_docs/tools ... le/#d0e788

...and remeber you can use the eclipse tools to create an initial reveng.xml file making it easier to start.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Reverse Engineer Database Problem
PostPosted: Wed Apr 05, 2006 5:38 am 
Beginner
Beginner

Joined: Fri May 21, 2004 5:22 am
Posts: 24
thanks max.

max wrote:
gigsvoo wrote:

Hibernate version: 3.1.0, Hibernate Tools version: 3.1.0 beta1


start by using the latest release.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.