-->
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.  [ 7 posts ] 
Author Message
 Post subject: ReverseEngineeringStrategy problem
PostPosted: Thu Sep 14, 2006 3:10 am 
Newbie

Joined: Tue Sep 05, 2006 8:23 am
Posts: 7
hi,

i'm having a problem with my custom rev eng strategy:
package reveng.strategy;

import org.hibernate.cfg.reveng.*;

public class BCOReverseEngineeringStrategy extends DelegatingReverseEngineeringStrategy
{
public BCOReverseEngineeringStrategy(ReverseEngineeringStrategy delegate)
{
super(delegate);
}

public String columnToPropertyName(TableIdentifier table, String column)
{
//if(column.endsWith("PK")) {return "id";}
// else { return super.columnToPropertyName(table, column);}
return column;
}
}


the problem is that ant does't know about this class; it is putted in the classpath of hibernatetool task; in fact i build a jar containing this class and i putted in the classpath; the jar is in the same dir with BCOHibernate.reveng.xml; ant knows about the reveng xml because the output says :
Code:
INFO: Override file: D:\eclipse fondi workspace\BancaCorrispondenteOnline_tests\varie\svil\svil_lib\BCOHibernate.reveng.xml


but it does'n know about the jar ; why ? it is in the same dir with the reveng xml, the jdbcconfiguration strategy attribute is
Code:
reversestrategy="reveng.strategy.BCOReverseEngineeringStrategy"

the reveng/strategy/BCOReverseEngineeringStrategy.class is the only thing that is contained in the jar.....i see no problem in all i've done;

here is the full buil.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>

<project name="BCO" default="all" basedir=".">

<target name="all" depends="generateMappingFilesAndJavaFiles,cutAndPasteTheHbmMappings" description="all"/>

<property name="ear" value="../ear"></property>
<property name="ear.war" value="${ear}/war"></property>
<property name="ear.war.webinf" value="${ear.war}/WEB-INF"></property>
<property name="ear.war.webinf.src_lib" value="${ear.war.webinf}/src_lib"></property>
<property name="ear.war.webinf.src_lib.persistence" value="${ear.war.webinf.src_lib}/persistence"></property>
<property name="ear.lib" value="${ear}/lib"></property>
<property name="ear.lib.hibernate" value="${ear.lib}/hibernate"></property>
<property name="ear.lib.hibernate.tools" value="${ear.lib.hibernate}/tools"></property>
<property name="varie" value="."></property>
<property name="varie.svil" value="${varie}/svil"></property>
<property name="varie.svil.hibernate" value="${varie.svil}/svil_hibernate"></property>
<property name="varie.svil.lib" value="${varie.svil}/svil_lib"></property>

<target name="buildRevengStrategyJar" description="builds the jar containg one class : BCOReverseEngineeringStrategy.class">
<delete>
      <fileset dir="${varie.svil.lib}" includes="revengStrategy.jar" />
</delete>
<jar destfile="${varie.svil.lib}/revengStrategy.jar" basedir="${varie.svil.hibernate}"  includes="reveng/strategy/BCOReverseEngineeringStrategy.class"/>
</target>

<path id="toolslib">
   <path location="${ear.lib.hibernate}/hibernate3.jar"></path>
   <path location="${ear.lib.hibernate.tools}/hibernate-tools.jar"></path>
   <path location="${ear.lib.hibernate.tools}/jtidy-r8-21122004.jar"></path>
    <path location="${ear.lib.hibernate.tools}/bsh-2.0b1.jar"></path>
    <path location="${ear.lib.hibernate.tools}/freemarker.jar"></path>   

    <path location="${varie.svil.lib}/ojdbc14-9.2.0.5.zip"></path>
   
    <path location="${ear.lib}/commons-logging-1.0.4.jar"></path>
    <path location="${ear.lib}/commons-collections-2.1.1.jar"></path>
    <path location="${ear.lib}/dom4j-1.6.1.jar"></path>
    <path location="${ear.lib}/ehcache-1.1.jar"></path>
    <path location="${ear.lib}/cglib-2.1.3.jar"></path>
    <path location="${ear.lib}/asm.jar"></path>
    <path location="${ear.lib}/asm-attrs.jar"></path>
   
    <path location="${ear.lib}/asm-attrs.jar"></path>
   
</path>

<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="toolslib"
/>


<target name="generateMappingFilesAndJavaFiles" description="reverse engineering from de database, and generates hbm.xml files and then the pojo code">

<hibernatetool destdir="${ear.war.webinf.src_lib.persistence}">

<classpath path="${varie.svil.lib}/revengStrategy.jar"/>

<!-- am scos
-->
<jdbcconfiguration
propertyfile="${ear.war.webinf}/hibernate.properties"
configurationfile="${ear.war.webinf}/hibernate.cfg.xml"
packagename="it.sella.bco.model.beans"
revengfile="${varie.svil.lib}/BCOHibernate.reveng.xml"
reversestrategy="reveng.strategy.BCOReverseEngineeringStrategy"
>

</jdbcconfiguration>

<hbm2hbmxml destdir="${ear.war.webinf.src_lib.persistence}" />

<hbm2java jdk5="false"/>

</hibernatetool>

</target>


<target name="cutAndPasteTheHbmMappings" description="copies the hbm files in it.sella.bco.hibernate.hbm directory">

<copy todir="${ear.war.webinf.src_lib.persistence}/it/sella/bco/hibernate/hbm">
      <fileset dir="${ear.war.webinf.src_lib.persistence}/it/sella/bco/model/beans">
        <include name="**/*.hbm.xml" />
      </fileset>
    </copy>

<delete>
      <fileset dir="${ear.war.webinf.src_lib.persistence}/it/sella/bco/model/beans" includes="*.hbm.xml" />
</delete>

</target>



</project>


and here is the complete output:
Code:
Buildfile: D:\eclipse fondi workspace\BancaCorrispondenteOnline_tests\varie\build BCOdataModel bindings and javaCode.xml
generateMappingFilesAndJavaFiles:
[hibernatetool] Executing Hibernate Tool with a JDBC Configuration (for reverse engineering)
[hibernatetool] 1. task: hbm2hbmxml (Generates a set of hbm.xml files)
[hibernatetool] Sep 14, 2006 10:00:34 AM org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: Hibernate 3.2 cr4
[hibernatetool] Sep 14, 2006 10:00:34 AM org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: hibernate.properties not found
[hibernatetool] Sep 14, 2006 10:00:34 AM org.hibernate.cfg.Environment buildBytecodeProvider
[hibernatetool] INFO: Bytecode provider name : cglib
[hibernatetool] Sep 14, 2006 10:00:34 AM org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: using JDK 1.4 java.sql.Timestamp handling
[hibernatetool] Sep 14, 2006 10:00:34 AM org.hibernate.cfg.Configuration configure
[hibernatetool] INFO: configuring from file: hibernate.cfg.xml
[hibernatetool] Sep 14, 2006 10:00:35 AM org.hibernate.cfg.Configuration doConfigure
[hibernatetool] INFO: Configured SessionFactory: null
[hibernatetool] Sep 14, 2006 10:00:35 AM org.hibernate.cfg.reveng.OverrideRepository addFile
[hibernatetool] INFO: Override file: D:\eclipse fondi workspace\BancaCorrispondenteOnline_tests\varie\svil\svil_lib\BCOHibernate.reveng.xml
[hibernatetool] An exception occurred while running exporter #2:hbm2hbmxml (Generates a set of hbm.xml files)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] Could not create or find reveng.strategy.BCOReverseEngineeringStrategy with one argument delegate constructor
[hibernatetool] java.lang.ClassNotFoundException: reveng.strategy.BCOReverseEngineeringStrategy
[hibernatetool] A class were not found in the classpath of the Ant task.
[hibernatetool] Ensure that the classpath contains the classes needed for Hibernate and your code are in the classpath.

BUILD FAILED
D:\eclipse fondi workspace\BancaCorrispondenteOnline_tests\varie\build BCOdataModel bindings and javaCode.xml:56: Could not create or find reveng.strategy.BCOReverseEngineeringStrategy with one argument delegate constructor

Total time: 1 second


please help,
Viorel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 14, 2006 3:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
put it together with the libs for the taskdef.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 14, 2006 3:31 am 
Newbie

Joined: Tue Sep 05, 2006 8:23 am
Posts: 7
i modified the build like this :
Code:
<path id="toolslib">
   <path location="${ear.lib.hibernate}/hibernate3.jar"></path>
   <path location="${ear.lib.hibernate.tools}/hibernate-tools.jar"></path>
   <path location="${ear.lib.hibernate.tools}/jtidy-r8-21122004.jar"></path>
    <path location="${ear.lib.hibernate.tools}/bsh-2.0b1.jar"></path>
    <path location="${ear.lib.hibernate.tools}/freemarker.jar"></path>   

    <path location="${varie.svil.lib}/ojdbc14-9.2.0.5.zip"></path>
    [b]<path location="${varie.svil.lib}/revengStrategy.jar"></path>[/b]
   
    <path location="${ear.lib}/commons-logging-1.0.4.jar"></path>
    <path location="${ear.lib}/commons-collections-2.1.1.jar"></path>
    <path location="${ear.lib}/dom4j-1.6.1.jar"></path>
    <path location="${ear.lib}/ehcache-1.1.jar"></path>
    <path location="${ear.lib}/cglib-2.1.3.jar"></path>
    <path location="${ear.lib}/asm.jar"></path>
    <path location="${ear.lib}/asm-attrs.jar"></path>
   
    <path location="${ear.lib}/asm-attrs.jar"></path>
   
</path>


the output is this :
Buildfile: D:\eclipse fondi workspace\BancaCorrispondenteOnline_tests\varie\build BCOdataModel bindings and javaCode.xml
generateMappingFilesAndJavaFiles:
[hibernatetool] Executing Hibernate Tool with a JDBC Configuration (for reverse engineering)
[hibernatetool] 1. task: hbm2hbmxml (Generates a set of hbm.xml files)
[hibernatetool] Sep 14, 2006 10:23:45 AM org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: Hibernate 3.2 cr4
[hibernatetool] Sep 14, 2006 10:23:45 AM org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: hibernate.properties not found
[hibernatetool] Sep 14, 2006 10:23:45 AM org.hibernate.cfg.Environment buildBytecodeProvider
[hibernatetool] INFO: Bytecode provider name : cglib
[hibernatetool] Sep 14, 2006 10:23:45 AM org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: using JDK 1.4 java.sql.Timestamp handling
[hibernatetool] Sep 14, 2006 10:23:45 AM org.hibernate.cfg.Configuration configure
[hibernatetool] INFO: configuring from file: hibernate.cfg.xml
[hibernatetool] Sep 14, 2006 10:23:45 AM org.hibernate.cfg.Configuration doConfigure
[hibernatetool] INFO: Configured SessionFactory: null
[hibernatetool] Sep 14, 2006 10:23:46 AM org.hibernate.cfg.reveng.OverrideRepository addFile
[hibernatetool] INFO: Override file: D:\eclipse fondi workspace\BancaCorrispondenteOnline_tests\varie\svil\svil_lib\BCOHibernate.reveng.xml

BUILD FAILED
java.lang.NoClassDefFoundError: reveng/strategy/BCOReverseEngineeringStrategy (wrong name: varie/svil/svil_hibernate/reveng/strategy/BCOReverseEngineeringStrategy)

Total time: 1 second


the dir varie/svil/svil_hibernate is the dir where the source and class are ; how did ant pick up this dir ??? and not the dir of the jar ???

thanks,
Viorel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 14, 2006 3:38 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
and the jar does not contain that dir structure ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 14, 2006 3:46 am 
Newbie

Joined: Tue Sep 05, 2006 8:23 am
Posts: 7
the jar contains ONLY the reveng/strategy/BCOReverseEngineeringStrategy.class and the metainf file;

the oracle driver zip from the same dir is also recognized..because if i run without my reveng strategy it loads the class OracleDriver.

thanks,
Viorel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 14, 2006 4:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
so somewhere in your paths you must be referring to the root of your directories....something is "mixed' up at least.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 14, 2006 4:47 am 
Newbie

Joined: Tue Sep 05, 2006 8:23 am
Posts: 7
originally, the build had:

Code:
<jar destfile="${varie.svil.lib}/revengStrategy.jar" basedir="${varie.svil.hibernate}"  includes="reveng/strategy/BCOReverseEngineeringStrategy.class"/>

(you can see the first post)

i tryied to run the build with :
Code:
<jar destfile="${varie.svil.lib}/revengStrategy.jar" basedir="${varie.svil.hibernate}/reveng/strategy/"  includes="BCOReverseEngineeringStrategy.class"/>

clearly didn't work because the jar contained one file and no directory;
so i corected to the original <jar> tag; i runed again....and maggivally worked......i guess it's about refresh....i don't know...but now i'm very pleased that it's work cause it began to drive me crazy...

thanks,
Viorel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.