-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problems generating annotation using <hbmtemplate> in
PostPosted: Tue Nov 04, 2008 9:18 am 
Newbie

Joined: Tue Nov 04, 2008 8:53 am
Posts: 3
I am having problems using the <hbmtemplate> goal in Maven, but only when I want to generate annotations. I have also successfully been able to generate the pojos with the same configuration using Hibernate Tools plugin(Version: 3.2.4.Alpha1) for Eclipse.

I have modified the freemarker templates to add the ability to generate oracle sequence annotations, otherwise they are copy of what is in the distribution.

Here is the hibernate tools entry in my pom.xml:

Code:
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>hibernate3-maven-plugin</artifactId>
        <version>2.0-alpha-2</version>
        <executions>
          <execution>
            <phase>process-test-resources</phase>
            <goals>
              <goal>hbm2ddl</goal>
            </goals>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>${jdbc.groupId}</groupId>
            <artifactId>${jdbc.artifactId}</artifactId>
            <version>${jdbc.version}</version>
          </dependency>
        </dependencies>
        <configuration>
          <componentProperties>
            <jdk5>true</jdk5>
            <ejb3>true</ejb3>
            <revengfile>${basedir}\hib-gen\hibernate.reveng.xml</revengfile>
            <configurationfile>${basedir}\hib-gen\hibernate.cfg.xml</configurationfile>
            <outputfilename>${basedir}\src\main\java</outputfilename>
            <templatepath>${basedir}\hib-gen\ftl\pojo</templatepath>
            <propertyfile>${basedir}\hib-gen\hibernate.properties</propertyfile>
         <filepattern>{package-name}\{class-name}.java</filepattern>
         <template>Pojo.ftl</template>           
            <packagename>com.intellidyne.rms.model</packagename>
            <skip>false</skip>
          </componentProperties>
        </configuration>
      </plugin>


And here is the resulting exception I receive in the maven logs:

Code:
07:50:49,902  INFO org.hibernate.tool.Version - Hibernate Tools 3.2.0.b9
07:50:50,230 ERROR freemarker.runtime -
Method public java.lang.String org.hibernate.tool.hbm2x.pojo.EntityPOJOClass.generateJoinColumnsAnnotation(org.hibernate.mapp
ing.Property) threw an exception when invoked on org.hibernate.tool.hbm2x.pojo.EntityPOJOClass(com.intellidyne.rms.model.RmsT
itle)
The problematic instruction:
----------
==> ${pojo.generateJoinColumnsAnnotation(property, cfg)} [on line 15, column 1 in Ejb3PropertyGetAnnotation.ftl]
in include "Ejb3PropertyGetAnnotation.ftl" [on line 1, column 1 in GetPropertyAnnotation.ftl]
in include "GetPropertyAnnotation.ftl" [on line 9, column 5 in PojoPropertyAccessors.ftl]
in include "PojoPropertyAccessors.ftl" [on line 19, column 1 in Pojo.ftl]
----------

Java backtrace for programmers:
----------
freemarker.template.TemplateModelException: Method public java.lang.String org.hibernate.tool.hbm2x.pojo.EntityPOJOClass.gene
rateJoinColumnsAnnotation(org.hibernate.mapping.Property) threw an exception when invoked on org.hibernate.tool.hbm2x.pojo.En
tityPOJOClass(com.intellidyne.rms.model.RmsTitle)
        at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:136)
        at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
        at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
        at freemarker.core.Expression.getStringValue(Expression.java:93)
        at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.MixedContent.accept(MixedContent.java:92)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.IfBlock.accept(IfBlock.java:82)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.MixedContent.accept(MixedContent.java:92)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.Environment.include(Environment.java:1375)
        at freemarker.core.Include.accept(Include.java:155)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.Environment.include(Environment.java:1375)
        at freemarker.core.Include.accept(Include.java:155)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.MixedContent.accept(MixedContent.java:92)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:160)
        at freemarker.core.Environment.visit(Environment.java:351)
        at freemarker.core.IteratorBlock.accept(IteratorBlock.java:95)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.MixedContent.accept(MixedContent.java:92)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.Environment.include(Environment.java:1375)
        at freemarker.core.Include.accept(Include.java:155)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.MixedContent.accept(MixedContent.java:92)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.IfBlock.accept(IfBlock.java:82)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.MixedContent.accept(MixedContent.java:92)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.Environment.visit(Environment.java:233)
        at freemarker.core.BlockAssignment.accept(BlockAssignment.java:83)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.MixedContent.accept(MixedContent.java:92)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.Environment.process(Environment.java:176)
        at freemarker.template.Template.process(Template.java:231)
        at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:247)
        at org.hibernate.tool.hbm2x.TemplateProducer.produceToString(TemplateProducer.java:67)
        at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.java:28)
        at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.java:97)
        at org.hibernate.tool.hbm2x.GenericExporter.exportPOJO(GenericExporter.java:146)
        at org.hibernate.tool.hbm2x.GenericExporter.exportPersistentClass(GenericExporter.java:135)
        at org.hibernate.tool.hbm2x.GenericExporter$2.process(GenericExporter.java:41)
        at org.hibernate.tool.hbm2x.GenericExporter.doStart(GenericExporter.java:126)
        at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java:95)
        at org.codehaus.mojo.hibernate3.HibernateExporterMojo.doExecute(HibernateExporterMojo.java:241)
        at org.codehaus.mojo.hibernate3.HibernateExporterMojo.execute(HibernateExporterMojo.java:140)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:512)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:482)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330
)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
        at freemarker.ext.beans.BeansWrapper.unwrapArguments(BeansWrapper.java:540)
        at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:109)
        ... 74 more
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error while processing template Pojo.ftl
1
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.hibernate.tool.hbm2x.ExporterException: Error while processing template Pojo.ftl
        at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:253)
        at org.hibernate.tool.hbm2x.TemplateProducer.produceToString(TemplateProducer.java:67)
        at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.java:28)
        at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.java:97)
        at org.hibernate.tool.hbm2x.GenericExporter.exportPOJO(GenericExporter.java:146)
        at org.hibernate.tool.hbm2x.GenericExporter.exportPersistentClass(GenericExporter.java:135)
        at org.hibernate.tool.hbm2x.GenericExporter$2.process(GenericExporter.java:41)
        at org.hibernate.tool.hbm2x.GenericExporter.doStart(GenericExporter.java:126)
        at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java:95)
        at org.codehaus.mojo.hibernate3.HibernateExporterMojo.doExecute(HibernateExporterMojo.java:241)
        at org.codehaus.mojo.hibernate3.HibernateExporterMojo.execute(HibernateExporterMojo.java:140)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:512)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:482)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330
)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: freemarker.template.TemplateModelException: Method public java.lang.String org.hibernate.tool.hbm2x.pojo.EntityPOJ
OClass.generateJoinColumnsAnnotation(org.hibernate.mapping.Property) threw an exception when invoked on org.hibernate.tool.hb
m2x.pojo.EntityPOJOClass(com.intellidyne.rms.model.RmsTitle)
        at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:136)
        at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
        at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
        at freemarker.core.Expression.getStringValue(Expression.java:93)
        at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.MixedContent.accept(MixedContent.java:92)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.IfBlock.accept(IfBlock.java:82)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.MixedContent.accept(MixedContent.java:92)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.Environment.include(Environment.java:1375)
        at freemarker.core.Include.accept(Include.java:155)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.Environment.include(Environment.java:1375)
        at freemarker.core.Include.accept(Include.java:155)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.MixedContent.accept(MixedContent.java:92)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:160)
        at freemarker.core.Environment.visit(Environment.java:351)
        at freemarker.core.IteratorBlock.accept(IteratorBlock.java:95)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.MixedContent.accept(MixedContent.java:92)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.Environment.include(Environment.java:1375)
        at freemarker.core.Include.accept(Include.java:155)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.MixedContent.accept(MixedContent.java:92)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.IfBlock.accept(IfBlock.java:82)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.MixedContent.accept(MixedContent.java:92)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.Environment.visit(Environment.java:233)
        at freemarker.core.BlockAssignment.accept(BlockAssignment.java:83)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.MixedContent.accept(MixedContent.java:92)
        at freemarker.core.Environment.visit(Environment.java:196)
        at freemarker.core.Environment.process(Environment.java:176)
        at freemarker.template.Template.process(Template.java:231)
        at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:247)
        ... 28 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
        at freemarker.ext.beans.BeansWrapper.unwrapArguments(BeansWrapper.java:540)
        at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:109)
        ... 74 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16 seconds
[INFO] Finished at: Tue Nov 04 07:50:50 EST 2008
07:50:50,637  INFO org.hibernate.connection.DriverManagerConnectionProvider - cleaning up connection pool: jdbc:oracle:thin:@
10.200.28.162:1521:devrms
[INFO] Final Memory: 8M/14M
[INFO] ------------------------------------------------------------------------



If I switch the configuration to not use ejb3, then the pojos are successfully generated. Any help to what I am doing wrong would be appreciated.

Thanks,
Michael


Top
 Profile  
 
 Post subject: Fixed with earlier version
PostPosted: Tue Nov 04, 2008 10:02 am 
Newbie

Joined: Tue Nov 04, 2008 8:53 am
Posts: 3
I added a dependency to an earlier version to Hibernate Tools in the pom and it seemed to fix the problem. Guess this issue is isolated to the latest version.

This is what I added:

Code:
          <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-tools</artifactId>
            <version>3.2.0.ga</version>
          </dependency>


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