-->
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.  [ 20 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Can't get H3 tools v3 to work with Ant
PostPosted: Mon Jun 27, 2005 4:58 pm 
Beginner
Beginner

Joined: Thu Jun 23, 2005 11:23 am
Posts: 36
Location: Lancashire, England
Note: This was originally posted in the 'users' forum, sorry!

Hibernate version: 3.0

Name and version of the database you are using: hsqldb_1_7_3_3

Hallo -- I'm really sorry if this is a dumb question, but I promise I've been looking all over for answers & I'm drawing a blank.
I'm trying to get the 2nd chapter example from Hibernate: A Developer's Notebook to work with H3.0 and the v3 tools -- I've been trying to use the hbm2java functionality, but it won't work. I've opened up the jar file and made changes to the pathnames in the Ant build file, and have been grandually working my way through a number of errors, but am really stuck on this one. The error I get is this:

Code:
Buildfile: C:\Documents and Settings\DougLivesey\workspace\ch02\build.xml
codegen:

BUILD FAILED
C:\Documents and Settings\DougLivesey\workspace\ch02\build.xml:46: Could not create type hbm2java due to java.lang.NoSuchMethodException: org.hibernate.tool.ant.Hbm2JavaGeneratorTask.<init>(org.apache.tools.ant.Project)

Total time: 1 second



My build file currently looks like this:


Code:
<?xml version="1.0"?>
<project name="Harnessing Hibernate: The Developer's Notebook" default="db" basedir=".">
   <!-- Set up properties containing important project directories -->
   <property name="source.root" value="src" />
   <property name="class.root" value="bin" />
   <property name="lib.dir" value="lib" />
   <property name="data.dir" value="data" />
   
   <!-- Set up the classpath for compilation and execution -->
   <path id="project.class.path">
      <!-- Include our own classes -->
      <pathelement location="${class.root}" />
      <!-- Include jars in the project library directory -->
      <fileset dir="${lib.dir}">
         <include name="**/*.jar" />
      </fileset>
   </path>
   
   <target name="db" description="Runs HSQLDB UI against the database file -- use when app is not running">
      <java classname="org.hsqldb.util.DatabaseManager" fork="yes">
         <classpath refid="project.class.path" />
         <arg value="-driver" />
         <arg value="org.hsqldb.jdbcDriver" />
         <arg value="-url" />
         <arg value="jdbc:hsqldb:${data.dir}/music" />
         <arg value="-user" />
         <arg value="sa" />
      </java>
   </target>
   
   <!-- Teach Ant how to use Hibernate's code generation tool -->
   <taskdef name="hbm2java"
         classname="org.hibernate.tool.ant.Hbm2JavaGeneratorTask"
           classpathref="project.class.path" />
   
   <!-- Generate the java code for all mapping files in our source tree -->
   <target name="codegen"
         description="Generate Java source from the O/R mapping files">
      <hbm2java output="${source.root}">
         <fileset dir="${source.root}">
            <include name="**/*.hbm.xml" />
         </fileset>
      </hbm2java>
   </target>
</project>



If there's any info anyone can point me to on getting this stuff to work, or any advice anyone can give, I'd be VERY grateful.
& if this is a dumb/previously documented question, I promise it's down to me being dumb, and not lazy!
Thanks for any & all advice,
doug.

_________________
Common sense is what tells you the world is flat.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 1:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
use tools.hibernate.org

the ant tasks have been unified/cleaned up.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 5:42 am 
Beginner
Beginner

Joined: Thu Jun 23, 2005 11:23 am
Posts: 36
Location: Lancashire, England
Thanks for that -- I'm trying to put it together now!
Does anyone have an example build.xml file that does anything like this with H3 & tools 3 that they could post?
I'm afraid that I'm not only a Hibernate newbie, but an Ant newbie, too!
So much to learn, so little time...
Cheers,
doug.

_________________
Common sense is what tells you the world is flat.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 5:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
there are examples in the docs!

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 6:23 am 
Beginner
Beginner

Joined: Thu Jun 23, 2005 11:23 am
Posts: 36
Location: Lancashire, England
Yeah, I've been trying to get them to work -- the problem is, I guess, that there's too much there that I am unfamiliar with, so I'm having a hard time tracing where exactly I'm going wrong. I was hoping for a complete build file that I could dissect & compare to what I'm trying to do.
For instance: the first example in the docs gives me the errors:
Code:
1   taskdef class org.hibernate.tool.ant.HibernateToolTask cannot be found   build.xml   ch02   line 32   28 June 2005 11:20:23
1   Task could not be defined within the Ant Editor context   build.xml   ch02   line 37   28 June 2005 11:20:23


The version of the code I have from the example (using the declarations in the build file listed above) is:
Code:
   <!-- Formally introduce Ant to the toolset? -->
   <taskdef name="hibernatetool"
         classpath="${lib.dir}"
           classname="org.hibernate.tool.ant.HibernateToolTask" />


The point here is not that I need a particular answer to a particular question, but I guess that I don't fully get the docs yet, & was hoping for anther point of reference.
(As I mentioned -- I'm no Einstein!)
Cheers,
doug.

_________________
Common sense is what tells you the world is flat.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 6:26 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
does your lib.dir included the needed libraries as listed in the docs ?

if not - we can't load it.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 7:09 am 
Beginner
Beginner

Joined: Thu Jun 23, 2005 11:23 am
Posts: 36
Location: Lancashire, England
Yes, everything is there, except where in the docs it lists velocity-tools-generic-1.4.jar, I have velocity-tools-generic-1.1.jar, which is odd, as the download I have is only a few days old.
Another possibility could be that I haven't added these jars to the Eclipse Java Build Path libraries, as I was hoping to do it all in Ant (figuring that this was possible & preferable to playing with alot of mixed settings that I don't understand yet).
Do either of those sound likely?
Thanks,
doug.

_________________
Common sense is what tells you the world is flat.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 7:13 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
run ant with -debug or -verbose to get a more error reporting

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 7:37 am 
Beginner
Beginner

Joined: Thu Jun 23, 2005 11:23 am
Posts: 36
Location: Lancashire, England
I tried running it in debug from Eclipse, but all I get is:
Code:
Buildfile: C:\Documents and Settings\DougLivesey\workspace\ch02\build.xml

BUILD FAILED
C:\Documents and Settings\DougLivesey\workspace\ch02\build.xml:34: taskdef class org.hibernate.tool.ant.HibernateToolTask cannot be found

Total time: 821 milliseconds


I've even tried hard-coding the library file, both as an absolute & a relative, but get the same error!
<tearings out of hair!>
I guess I could try registering the jars in Eclipse, but even if that works, I hate things that work & I don't know why!
Or things that I should be able to get to work, but can't, & don't know why!
Cheers,
doug.

_________________
Common sense is what tells you the world is flat.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 7:40 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
try running it from outside eclipse - always rule out any interferring noise when debugging ,)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 11:31 am 
Beginner
Beginner

Joined: Thu Jun 23, 2005 11:23 am
Posts: 36
Location: Lancashire, England
That certainly looks to be the next step -- will post on how I go on, but could be a while -- going to have to spend some time w/ the Ant docs!
Cheers for your input, man!
doug.

_________________
Common sense is what tells you the world is flat.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2005 7:04 am 
Beginner
Beginner

Joined: Thu Jun 23, 2005 11:23 am
Posts: 36
Location: Lancashire, England
Thanks again for your input -- have decided that I need to maybe rephrase & repost my question, as I just keep hitting numberous walls!
The Ant docs did help my last problem, but I am hitting MANY others, so am going to see if anyone has a walk-through tutorial or FAQ using H3 & Ant tools 3 that I can follow & at least have some better idea of where reality is sadly departing from directions!
Cheers again,
doug.

_________________
Common sense is what tells you the world is flat.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2005 7:19 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
there is none that i know of yet ,)

so please just show what you have in your build.xml and what issues you get...

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2005 7:49 am 
Beginner
Beginner

Joined: Thu Jun 23, 2005 11:23 am
Posts: 36
Location: Lancashire, England
Thanks, man -- what I currently have as my build.xml file is:
Code:
<?xml version="1.0"?>
<project name="Harnessing Hibernate: The Developer's Notebook" default="db" basedir=".">
   <!-- Set up properties containing important project directories -->
   <property name="source.root" value="src" />
   <property name="class.root" value="bin" />
   <property name="lib.dir" value="lib" />
   <property name="data.dir" value="data" />
   
   <!-- Set up the classpath for compilation and execution -->
   <path id="project.class.path">
      <!-- Include our own classes -->
      <pathelement location="${class.root}" />
      <!-- Include jars in the project library directory -->
      <fileset dir="${lib.dir}">
         <include name="**/*.jar" />
      </fileset>
   </path>
   
   <target name="db" description="Runs HSQLDB UI against the database file -- use when app is not running">
      <java classname="org.hsqldb.util.DatabaseManager" fork="yes">
         <classpath refid="project.class.path" />
         <arg value="-driver" />
         <arg value="org.hsqldb.jdbcDriver" />
         <arg value="-url" />
         <arg value="jdbc:hsqldb:${data.dir}/music" />
         <arg value="-user" />
         <arg value="sa" />
      </java>
      <echo message="source.root='${source.root}'" />
      <echo message="class.root='${class.root}'" />
      <echo message="lib.dir='${lib.dir}'" />
      <echo message="data.dir='${data.dir}'" />
      <echo message="ant.home='${ant.home}'" />
      <echo message="basedir='${basedir}'" />
   </target>

   <!-- Formally introduce Ant to the toolset -->
   <taskdef name="hibernatetool"
           classname="org.hibernate.tool.ant.HibernateToolTask">
         <classpath refid="project.class.path" />
   </taskdef>
   
   <!-- bit of a best guess, I'm afraid -->
   <hibernatetool destdir="${source.root}">
      <classpath refid="project.class.path" />
      <configuration propertyFile="src/hibernate.properties">
         <fileset dir="${source.root}">
            <include name="**/*.hbm.xml" />
         </fileset>
      </configuration>
      <hbm2java />
      <hbm2ddl />
   </hibernatetool>

</project>


I currently get the following errors when I try to run the default db target:
Code:
Buildfile: C:\Documents and Settings\DougLivesey\workspace\ch02\build.xml
[hibernatetool] Executing Hibernate Tool with a Standard Configuration
[hibernatetool] 1. task: hbm2java (Generates a set of .java files)

BUILD FAILED
java.lang.ExceptionInInitializerError
   at org.hibernate.tool.ant.Hbm2JavaGeneratorTask.createExporter(Hbm2JavaGeneratorTask.java:44)
   at org.hibernate.tool.ant.GeneratorTask.execute(GeneratorTask.java:32)
   at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:115)
   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.helper.ProjectHelper2.parse(ProjectHelper2.java:142)
   at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.parseBuildFile(InternalAntRunner.java:192)
   at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:394)
   at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:138)
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. (Caused by org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.) (Caused by org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. (Caused by org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.))
   at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
   at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
   at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
   at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
   at org.hibernate.tool.hbm2x.POJOExporter.<clinit>(POJOExporter.java:26)
   ... 10 more
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. (Caused by org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.)
   at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
   at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
   ... 14 more
Caused by: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.
   at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:385)
   ... 15 more

Total time: 2 seconds


The db target actually runs OK if I comment out the lines:
Code:
      <hbm2java />
      <hbm2ddl />


I do have a log4j.properties file in place.
What I really want to be able to do is to create a target called codegen that generates the code, but don't really understand what's going on. (Like I say, I'm trying to stick as much as possible to the Developer's Notebook examples so that I can recreate functionality for my own project.)
& cheers again -- dufuses must be quite frustrating!
doug.

_________________
Common sense is what tells you the world is flat.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 29, 2005 7:53 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
eh, the exception says it all ,)

you have more than one .jar (or duplicates in different classpaths) of commons.logging - don't do that ,)

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 20 posts ]  Go to page 1, 2  Next

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.