[hibernate-issues] [Hibernate-JIRA] Created: (HBX-1059) generating with generic hbmtemplate and maven 1.1
Nicolas Andres (JIRA)
noreply at atlassian.com
Tue May 6 10:20:33 EDT 2008
generating with generic hbmtemplate and maven 1.1
--------------------------------------------------
Key: HBX-1059
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-1059
Project: Hibernate Tools
Issue Type: Improvement
Components: datagen
Affects Versions: 3.2.beta11
Environment: hibernate 3.2.6, maven 1.1, ant 1.6.5
Reporter: Nicolas Andres
Priority: Blocker
There is a problem referencing the freemarker templates when using maven 1.1. The hibernate-tools.jar and freemarker.jar have to be referenced in the POM file with the tag <classloader>root</classloader> otherwise the classes are not found when executing the hbmtemplate task. The defined classpath (<ant:classpath>....) will be loaded by a different classloader (AntClassLoader) which has the root classloader as parent classloader. So, I do not see a way to reference the ftl templates in the ant:classpath.
Unfortunately, the freemarker templates can only be referenced relative to the classpath and not as absolute file names. Because maven does not support to load resources on the root classpath (unlike jars) it is not possible to use hibernate tools as shown below.
from project.xml:
<dependency>
<groupId>lgpl</groupId>
<artifactId>hibernate-tools</artifactId>
<version>3.2.0b11</version>
<type>jar</type>
<properties>
<classloader>root</classloader>
<ejb.manifest.classpath>false</ejb.manifest.classpath>
</properties>
</dependency>
from maven.mxl:
<ant:taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
/>
<ant:hibernatetool destdir="${hibernate.gen.destdir}">
<ant:configuration configurationfile="${hibernate.cfg}" />
<ant:hbmtemplate template="hibernateDao.ftl" filepattern="{package-name}/{class-name}HibernateDao.java" />
<ant:classpath>
<ant:pathelement path="${basedir}/../src/main/resources"/>
</ant:classpath>
</ant:hibernatetool>
console:
Exception stack traces :
org.apache.maven.werkz.UnattainableGoalException: Unable to obtain goal [generate]
at org.apache.maven.werkz.Goal.fire(Goal.java:698)
at org.apache.maven.werkz.Goal.attain(Goal.java:623)
at org.apache.maven.plugin.PluginManager.attainGoals(PluginManager.java:712)
at org.apache.maven.MavenSession.attainGoals(MavenSession.java:265)
at org.apache.maven.cli.App.doMain(App.java:307)
at org.apache.maven.cli.App.main(App.java:217)
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:324)
at com.werken.forehead.Forehead.run(Forehead.java:551)
at com.werken.forehead.Forehead.main(Forehead.java:581)
Caused by: org.apache.commons.jelly.JellyTagException: file:/C:/Documents and Settings/s74342/IBM/rationalsdp7.0/workspace/eum-ejb/maven/maven.xml:57:56: <ant:hibernatetool> org.hibernate.tool.hbm2x.ExporterException: Error while processing template hibernateDao.ftl
at org.apache.commons.jelly.impl.TagScript.handleException(TagScript.java:681)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:262)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at org.apache.maven.jelly.tags.werkz.MavenGoalTag.runBodyTag(MavenGoalTag.java:83)
at org.apache.maven.jelly.tags.werkz.MavenGoalTag$MavenGoalAction.performAction(MavenGoalTag.java:116)
at org.apache.maven.werkz.Goal.fire(Goal.java:691)
at org.apache.maven.werkz.Goal.attain(Goal.java:623)
at org.apache.maven.werkz.WerkzProject.attainGoal(WerkzProject.java:209)
at org.apache.maven.jelly.tags.werkz.MavenAttainGoalTag.doTag(MavenAttainGoalTag.java:115)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:250)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at org.apache.maven.jelly.tags.werkz.MavenGoalTag.runBodyTag(MavenGoalTag.java:83)
at org.apache.maven.jelly.tags.werkz.MavenGoalTag$MavenGoalAction.performAction(MavenGoalTag.java:116)
at org.apache.maven.werkz.Goal.fire(Goal.java:691)
... 11 more
Caused by: org.hibernate.tool.hbm2x.ExporterException: Error while processing template hibernateDao.ftl
at org.hibernate.tool.ant.HibernateToolTask.reportException(HibernateToolTask.java:226)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:189)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:195)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:250)
... 23 more
Caused by: org.hibernate.tool.hbm2x.ExporterException: Error while processing template hibernateDao.ftl
at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:254)
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.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:40)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
... 26 more
Caused by: java.io.FileNotFoundException: Template hibernateDao.ftl not found.
at freemarker.template.Configuration.getTemplate(Configuration.java:489)
at freemarker.template.Configuration.getTemplate(Configuration.java:452)
at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:250)
... 36 more
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list