-->
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.  [ 4 posts ] 
Author Message
 Post subject: hbm2java, codegen
PostPosted: Tue Nov 01, 2005 11:50 am 
Newbie

Joined: Tue Nov 01, 2005 11:43 am
Posts: 2
Location: Sweden
Im trying to generate my java-classes using hibernate-tools (3.0beta1), the eclipse-plugin works flawless but the ant-task won't produce any classes.

My ant-target (
Code:
   <target name="generate-pojo"
      description="Build the pojo's from hbm config">
      <hibernatetool destdir="${build.dir}/bottomup">
         
         <configuration configurationfile="${src.java.dir}/dao/hibernate.cfg.xml"><!--propertyfile="mainhibernate.properties"-->
            <fileset dir="${src.java.dir}/dao">
               <include name="**/*.hbm.xml" />
            </fileset>       
         </configuration>
         
         <hbm2java/>
      </hibernatetool>
   </target>

    <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask">
       <classpath>
            <path refid="hibernatetool.classpath"/>
       </classpath>
   </taskdef>

    <path id="hibernatetool.classpath">
        <path refid="hibernate.classpath"/>
      <pathelement location="${hibernate.tools.dir}/hibernate-tools.jar"/>
      <pathelement location="${hibernate.tools.dir}/velocity-1.4.jar"/>
      <pathelement location="${hibernate.tools.dir}/velocity-tools-generic-1.1.jar"/>
      <pathelement location="${hibernate.tools.dir}/jtidy-r8-21122004.jar"/>
        <pathelement location="${commons-logging.jar}"/>
        <pathelement location="${commons-collections.jar}"/>
        <pathelement location="${log4j.jar}"/>
    </path>   



Running this gives me the following stacktrace when run in verbose.

Code:
BUILD FAILED
D:\tmp\workspace\skeleton\build.xml:144: org.hibernate.tool.hbm2x.ExporterExcept
ion: MethodInvocationException while processing template Pojo. Invocation of met
hod 'get' in  class org.hibernate.tool.hbm2x.TemplateHelper$Templates threw exce
ption class org.hibernate.tool.hbm2x.ExporterException : MethodInvocationExcepti
on while processing template pojo/PojoEqualsHashcode.vm. Invocation of method 'n
eedsEqualsHashCode' in  class org.hibernate.tool.hbm2x.pojo.EntityPOJOClass thre
w exception class java.lang.NoSuchMethodError : org.hibernate.mapping.Property.i
sNaturalIdentifier()Z
        at org.apache.tools.ant.Task.perform(Task.java:373)
        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.executeSortedTargets(Project.java:1216)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
cutor.java:40)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
        at org.apache.tools.ant.Main.runBuild(Main.java:668)
        at org.apache.tools.ant.Main.startAnt(Main.java:187)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Caused by: org.hibernate.tool.hbm2x.ExporterException: MethodInvocationException
while processing template Pojo. Invocation of method 'get' in  class org.hibern
ate.tool.hbm2x.TemplateHelper$Templates threw exception class org.hibernate.tool
.hbm2x.ExporterException : MethodInvocationException while processing template p
ojo/PojoEqualsHashcode.vm. Invocation of method 'needsEqualsHashCode' in  class
org.hibernate.tool.hbm2x.pojo.EntityPOJOClass threw exception class java.lang.No
SuchMethodError : org.hibernate.mapping.Property.isNaturalIdentifier()Z
        at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelpe
r.java:140)
        at org.hibernate.tool.hbm2x.VelocityProducer.firstPass(VelocityProducer.
java:72)
        at org.hibernate.tool.hbm2x.VelocityProducer.produce(VelocityProducer.ja
va:27)
        at org.hibernate.tool.hbm2x.VelocityProducer.produce(VelocityProducer.ja
va:104)
        at org.hibernate.tool.hbm2x.GenericExporter.exportPOJO(GenericExporter.j
ava:112)
        at org.hibernate.tool.hbm2x.GenericExporter.exportPersistentClass(Generi
cExporter.java:100)
        at org.hibernate.tool.hbm2x.GenericExporter.exportClasses(GenericExporte
r.java:83)
        at org.hibernate.tool.hbm2x.GenericExporter.doStart(GenericExporter.java
:68)
        at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java
:90)
        at org.hibernate.tool.hbm2x.GenericExporter.start(GenericExporter.java:5
8)
        at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)
        at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.ja
va:144)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        ... 10 more
Caused by: org.hibernate.tool.hbm2x.ExporterException: MethodInvocationException
while processing template pojo/PojoEqualsHashcode.vm. Invocation of method 'nee
dsEqualsHashCode' in  class org.hibernate.tool.hbm2x.pojo.EntityPOJOClass threw
exception class java.lang.NoSuchMethodError : org.hibernate.mapping.Property.isN
aturalIdentifier()Z
        at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelpe
r.java:140)
        at org.hibernate.tool.hbm2x.TemplateHelper$Templates.get(TemplateHelper.
java:98)
        at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at org.apache.velocity.runtime.parser.node.GetExecutor.execute(GetExecut
or.java:65)
        at org.apache.velocity.util.introspection.UberspectImpl$VelGetterImpl.in
voke(UberspectImpl.java:302)
        at org.apache.velocity.runtime.parser.node.ASTIdentifier.execute(ASTIden
tifier.java:157)
        at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTRefer
ence.java:175)
        at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTRefere
nce.java:220)
        at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java
:55)
        at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfSt
atement.java:70)
        at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.
java:230)
        at org.apache.velocity.Template.merge(Template.java:256)
        at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.j
ava:450)
        at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.j
ava:419)
        at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelpe
r.java:128)
        ... 23 more
Caused by: java.lang.NoSuchMethodError: org.hibernate.mapping.Property.isNatural
Identifier()Z
        at org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.usePropertyInEquals(Basi
cPOJOClass.java:207)
        at org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.needsEqualsHashCode(Basi
cPOJOClass.java:249)
        at org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.needsEqualsHashCode(Basi
cPOJOClass.java:258)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.in
voke(UberspectImpl.java:267)
        at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.j
ava:197)
        at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTRefer
ence.java:175)
        at org.apache.velocity.runtime.parser.node.ASTReference.evaluate(ASTRefe
rence.java:307)
        at org.apache.velocity.runtime.parser.node.ASTAndNode.evaluate(ASTAndNod
e.java:89)
        at org.apache.velocity.runtime.parser.node.ASTExpression.evaluate(ASTExp
ression.java:45)
        at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfSt
atement.java:68)
        at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.
java:230)
        at org.apache.velocity.Template.merge(Template.java:256)
        at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.j
ava:450)
        at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.j
ava:419)
        at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelpe
r.java:128)
        ... 39 more
--- Nested Exception ---
org.hibernate.tool.hbm2x.ExporterException: MethodInvocationException while proc
essing template Pojo. Invocation of method 'get' in  class org.hibernate.tool.hb
m2x.TemplateHelper$Templates threw exception class org.hibernate.tool.hbm2x.Expo
rterException : MethodInvocationException while processing template pojo/PojoEqu
alsHashcode.vm. Invocation of method 'needsEqualsHashCode' in  class org.hiberna
te.tool.hbm2x.pojo.EntityPOJOClass threw exception class java.lang.NoSuchMethodE
rror : org.hibernate.mapping.Property.isNaturalIdentifier()Z
        at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelpe
r.java:140)
        at org.hibernate.tool.hbm2x.VelocityProducer.firstPass(VelocityProducer.
java:72)
        at org.hibernate.tool.hbm2x.VelocityProducer.produce(VelocityProducer.ja
va:27)
        at org.hibernate.tool.hbm2x.VelocityProducer.produce(VelocityProducer.ja
va:104)
        at org.hibernate.tool.hbm2x.GenericExporter.exportPOJO(GenericExporter.j
ava:112)
        at org.hibernate.tool.hbm2x.GenericExporter.exportPersistentClass(Generi
cExporter.java:100)
        at org.hibernate.tool.hbm2x.GenericExporter.exportClasses(GenericExporte
r.java:83)
        at org.hibernate.tool.hbm2x.GenericExporter.doStart(GenericExporter.java
:68)
        at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java
:90)
        at org.hibernate.tool.hbm2x.GenericExporter.start(GenericExporter.java:5
8)
        at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)
        at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.ja
va: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.executeSortedTargets(Project.java:1216)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
cutor.java:40)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
        at org.apache.tools.ant.Main.runBuild(Main.java:668)
        at org.apache.tools.ant.Main.startAnt(Main.java:187)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Caused by: org.hibernate.tool.hbm2x.ExporterException: MethodInvocationException
while processing template pojo/PojoEqualsHashcode.vm. Invocation of method 'nee
dsEqualsHashCode' in  class org.hibernate.tool.hbm2x.pojo.EntityPOJOClass threw
exception class java.lang.NoSuchMethodError : org.hibernate.mapping.Property.isN
aturalIdentifier()Z
        at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelpe
r.java:140)
        at org.hibernate.tool.hbm2x.TemplateHelper$Templates.get(TemplateHelper.
java:98)
        at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at org.apache.velocity.runtime.parser.node.GetExecutor.execute(GetExecut
or.java:65)
        at org.apache.velocity.util.introspection.UberspectImpl$VelGetterImpl.in
voke(UberspectImpl.java:302)
        at org.apache.velocity.runtime.parser.node.ASTIdentifier.execute(ASTIden
tifier.java:157)
        at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTRefer
ence.java:175)
        at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTRefere
nce.java:220)
        at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java
:55)
        at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfSt
atement.java:70)
        at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.
java:230)
        at org.apache.velocity.Template.merge(Template.java:256)
        at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.j
ava:450)
        at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.j
ava:419)
        at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelpe
r.java:128)
        ... 23 more
Caused by: java.lang.NoSuchMethodError: org.hibernate.mapping.Property.isNatural
Identifier()Z
        at org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.usePropertyInEquals(Basi
cPOJOClass.java:207)
        at org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.needsEqualsHashCode(Basi
cPOJOClass.java:249)
        at org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.needsEqualsHashCode(Basi
cPOJOClass.java:258)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.in
voke(UberspectImpl.java:267)
        at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.j
ava:197)
        at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTRefer
ence.java:175)
        at org.apache.velocity.runtime.parser.node.ASTReference.evaluate(ASTRefe
rence.java:307)
        at org.apache.velocity.runtime.parser.node.ASTAndNode.evaluate(ASTAndNod
e.java:89)
        at org.apache.velocity.runtime.parser.node.ASTExpression.evaluate(ASTExp
ression.java:45)
        at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfSt
atement.java:68)
        at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.
java:230)
        at org.apache.velocity.Template.merge(Template.java:256)
        at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.j
ava:450)
        at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.j
ava:419)
        at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelpe
r.java:128)
        ... 39 more


Any suggestions??


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 01, 2005 12:31 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
the exporters run by the ant tasks are the same exporters that are run by the eclipse plug in. check to see if that ant tasks have different jar files in the classpath.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 01, 2005 1:47 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
and use the hibernate that comes with the tools (in this case its h3.1 rc1, but much easier to just use the hibernate that comes with the tools)

note: you can still use another H3.x for your runtime stuff.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 02, 2005 2:57 am 
Newbie

Joined: Tue Nov 01, 2005 11:43 am
Posts: 2
Location: Sweden
max wrote:
and use the hibernate that comes with the tools (in this case its h3.1 rc1, but much easier to just use the hibernate that comes with the tools)

note: you can still use another H3.x for your runtime stuff.


Thanks Max, this solved it.

I troubleshot it by copying all of the hibernate/*.jar files from the tool-directory, and put one jar in at a time. Using the hibernate3.jar delivered with the plug-in when generation the artifacts solved the problem.


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