-->
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.  [ 8 posts ] 
Author Message
 Post subject: Hbm2Java Ant Task
PostPosted: Tue Oct 21, 2003 1:39 pm 
Newbie

Joined: Wed Oct 01, 2003 1:12 pm
Posts: 9
The following target doesn't work:
Code:
    <target name="hibernate_to_java"
       description="Generate .java from .hbm files."
       depends="hibernate-acer-tl_anagrafica_audit"
       >

    <taskdef name="hbm2java"
        classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
        classpathref="lib.class.path"/>

       <hbm2java config="${config.dir}/hbm2java.xml"
          output="${java.export.dir}"
       >
          <fileset dir="${xml.export.dir}">
               <include name="**/*.hbm.xml"/>
          </fileset>
      </hbm2java>
   </target>


and causes the following error:
Code:
C:\java\hibernate_generator\build.xml:237: Caused by:
Caused by:
java.lang.NoClassDefFoundError: net/sf/hibernate/MappingException
        at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.processFile(Hbm2JavaTask.java:145)
        at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.execute(Hbm2JavaTask.java:95)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:302)
        at org.apache.tools.ant.Task.perform(Task.java:401)
        at org.apache.tools.ant.Target.execute(Target.java:338)
        at org.apache.tools.ant.Target.performTasks(Target.java:365)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1237)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1094)
        at org.apache.tools.ant.Main.runBuild(Main.java:669)
        at org.apache.tools.ant.Main.startAnt(Main.java:220)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:215)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:90)

        at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.processFile(Hbm2JavaTask.java:149)
        at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.execute(Hbm2JavaTask.java:95)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:302)
        at org.apache.tools.ant.Task.perform(Task.java:401)
        at org.apache.tools.ant.Target.execute(Target.java:338)
        at org.apache.tools.ant.Target.performTasks(Target.java:365)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1237)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1094)
        at org.apache.tools.ant.Main.runBuild(Main.java:669)
        at org.apache.tools.ant.Main.startAnt(Main.java:220)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:215)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:90)


but the following target works perfectly !
Both target are from the same build.xml file and have the same classpathref set to ${lib.class.path}.
I'm stuck!
Of course I don't want to list all the xml mapping files and I'd like to use Ant's fileset feature with Hbm2JavaTask.

Code:
   <target name="alt-hbm2java" description="Generate ValueObject From Mapping Files">
      <java classname="net.sf.hibernate.tool.hbm2java.CodeGenerator" classpathref="lib.class.path">
         <arg value="--output=${java.export.dir}"/>
         <arg value="${xml.export.dir}\it\tlasf\db\audit\hibernate\model\Action.hbm.xml"/>
      </java>
   </target>


Please help me.
Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 21, 2003 8:31 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
The task you are using looks find as its about the same as the version we use in the tools example. It is likely to be a path issue.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 21, 2003 8:41 pm 
Newbie

Joined: Wed Oct 01, 2003 1:12 pm
Posts: 9
david wrote:
The task you are using looks find as its about the same as the version we use in the tools example. It is likely to be a path issue.


But if it were a path issue, since the path is the same for both targets, the only reason for the failure could be that the Hbm2JavaTask class uses more libraries than CodeGenerator class. And if this is true, I'd like to know which are these libraries I need to add to the classpath.

Thanks again for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 21, 2003 8:48 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Get the tools package from the example page and have a look. It works fine and will provide the basis for a solution.


Top
 Profile  
 
 Post subject: Still not working...
PostPosted: Wed Oct 22, 2003 5:21 am 
Newbie

Joined: Wed Oct 01, 2003 1:12 pm
Posts: 9
david wrote:
Get the tools package from the example page and have a look. It works fine and will provide the basis for a solution.


I ran the tools package and all target work except the hbm2java one: I got the same error as in my build.xml.

I don't know what to do! I don't think there is anything particular in my environment:

Code:
ALLUSERSPROFILE=C:\Documents and Settings\All Users
ANT_HOME=c:\java\ant
APPDATA=C:\Documents and Settings\marcius\Dati applicazioni
CommonProgramFiles=C:\Programmi\File comuni
COMPUTERNAME=ACER
ComSpec=C:\WINDOWS\system32\cmd.exe
HOMEDRIVE=C:
HOMEPATH=\Documents and Settings\marcius
JAVA_HOME=c:\Programmi\j2sdk1.4.1_02
LOGONSERVER=\\ACER
MYSQL_HOME=c:\programmi\mysql
MY_JAVA_HOME=c:\java
NUMBER_OF_PROCESSORS=1
OS=Windows_NT
Path=c:\java\ant\bin;c:\programmi\mysql\bin;c:\Programmi\j2sdk1.4.1_02\bin;c:\apache\perl\bin\;c:\Perl\bin\;C:\Programmi\Borland\Delphi7\Bin;C:\Programmi\Borland\Delphi7\Projects\Bpl\;C:\WINDOWS\system32;C:\WINDOWS;
C:\WINDOWS\System32\Wbem;C:\Programmi\Microsoft SQL Server\80\Tools\BINN;C:\Programmi\UltraEdit;C:\Programmi\cvsnt;
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 15 Model 2 Stepping 7, GenuineIntel
PROCESSOR_LEVEL=15
PROCESSOR_REVISION=0207
ProgramFiles=C:\Programmi
PROMPT=$P$G
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\WINDOWS
TEMP=C:\DOCUME~1\marcius\IMPOST~1\Temp
TMP=C:\DOCUME~1\marcius\IMPOST~1\Temp
USERDOMAIN=ACER
USERNAME=marcius
USERPROFILE=C:\Documents and Settings\marcius
windir=C:\WINDOWS


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 22, 2003 8:44 am 
Beginner
Beginner

Joined: Thu Sep 25, 2003 5:22 pm
Posts: 29
Location: NC
What does your lib.class.path look like? What jars are included in the directories that are in that path?

-Kat


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 22, 2003 9:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
The problem will end up being a environment issue, so as ugly as it is here is my environment setup script for the tools demo.

rem This is a basic environment script for the Hibernate Example.
@set ClassPath=D:\jdk1.4.2\lib\tools.jar;.;D:\apps\apache-ant-1.5.4\lib\ant.jar;D:\apps\apache-ant-1.5.4\lib\xercesImpl.jar;D:\apps\apache-ant-1.5.4\lib\xml-apis.jar
@set Path=D:\jdk1.4.2\bin;D:\jdk1.4.2\jre\bin;C:\WINNT\SYSTEM32;C:\WINNT;D:\cygnus\cygwin-b20\H-i586-cygwin32\bin;D:\apps\apache-ant-1.5.4\bin
@echo %ClassPath%
@echo %Path%
@set JAVA_HOME=D:\jdk1.4.2
@set ANT_HOME=D:\apps\apache-ant-1.5.4


Top
 Profile  
 
 Post subject: Solved
PostPosted: Wed Nov 05, 2003 8:03 am 
Newbie

Joined: Wed Oct 01, 2003 1:12 pm
Posts: 9
I found the problem! You were all right: it was a classpath issue.
In my classpath (see below) I am including all jars in ${lib.common.dir}/hibernate and guess what ? There was an older hibernate-tools.jar renamed to _hibernate-tools.jar that actually was loaded before the good one. Me stupid!

Quote:
<path id="lib.class.path">
<pathelement path="${database.driver.classpath}"/>
<fileset dir="${lib.common.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${lib.common.dir}/middlegen">
<include name="*.jar"/>
</fileset>
<fileset dir="${lib.common.dir}/hibernate">
<include name="*.jar"/>
</fileset>
</path>


Thanks to everybody for help and excuse me!


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