org.apache.maven.werkz.UnattainableGoalException: Unable to obtain goal [generate]

Hibernate JIRA | Nicolas Andres | 9 years ago
  1. 0

    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

    Hibernate JIRA | 9 years ago | Nicolas Andres
    org.apache.maven.werkz.UnattainableGoalException: Unable to obtain goal [generate]
  2. 0

    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

    Hibernate JIRA | 9 years ago | Nicolas Andres
    org.apache.maven.werkz.UnattainableGoalException: Unable to obtain goal [generate]
  3. 0

    Problem when using parameter type Date

    oreports | 9 years ago | luonghuutinh
    java.io.FileNotFoundException: Template /template/simple/checkbox.ftl not found.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Template loading problem.

    freemarker | 9 years ago | yaroslavsh
    java.io.FileNotFoundException: Template http://localhost:xxxx/my\_template.ftl not found.
  6. 0

    problem in printing the values

    Coderanch | 6 years ago | madhuri kunchala
    java.io.FileNotFoundException: Template /template/xhtml/false.ftl not found.

    2 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.io.FileNotFoundException

      Template hibernateDao.ftl not found.

      at freemarker.template.Configuration.getTemplate()
    2. FreeMarker
      Configuration.getTemplate
      1. freemarker.template.Configuration.getTemplate(Configuration.java:489)
      2. freemarker.template.Configuration.getTemplate(Configuration.java:452)
      2 frames
    3. Hibernate Tools
      AbstractExporter.start
      1. org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:250)
      2. org.hibernate.tool.hbm2x.TemplateProducer.produceToString(TemplateProducer.java:67)
      3. org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.java:28)
      4. org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.java:97)
      5. org.hibernate.tool.hbm2x.GenericExporter.exportPOJO(GenericExporter.java:146)
      6. org.hibernate.tool.hbm2x.GenericExporter.exportPersistentClass(GenericExporter.java:135)
      7. org.hibernate.tool.hbm2x.GenericExporter$2.process(GenericExporter.java:41)
      8. org.hibernate.tool.hbm2x.GenericExporter.doStart(GenericExporter.java:126)
      9. org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java:95)
      9 frames
    4. A Hibernate O/RM Module
      HibernateToolTask.execute
      1. org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:40)
      2. org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
      2 frames
    5. Ant
      Task.perform
      1. org.apache.tools.ant.Task.perform(Task.java:364)
      1 frame
    6. commons-jelly-tags-antlr
      AntTag.doTag
      1. org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:195)
      1 frame
    7. commons-jelly
      ScriptBlock.run
      1. org.apache.commons.jelly.impl.TagScript.run(TagScript.java:250)
      2. org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
      2 frames
    8. org.apache.maven
      MavenAttainGoalTag.doTag
      1. org.apache.maven.jelly.tags.werkz.MavenGoalTag.runBodyTag(MavenGoalTag.java:83)
      2. org.apache.maven.jelly.tags.werkz.MavenGoalTag$MavenGoalAction.performAction(MavenGoalTag.java:116)
      3. org.apache.maven.werkz.Goal.fire(Goal.java:691)
      4. org.apache.maven.werkz.Goal.attain(Goal.java:623)
      5. org.apache.maven.werkz.WerkzProject.attainGoal(WerkzProject.java:209)
      6. org.apache.maven.jelly.tags.werkz.MavenAttainGoalTag.doTag(MavenAttainGoalTag.java:115)
      6 frames
    9. commons-jelly
      ScriptBlock.run
      1. org.apache.commons.jelly.impl.TagScript.run(TagScript.java:250)
      2. org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
      2 frames
    10. org.apache.maven
      Goal.attain
      1. org.apache.maven.jelly.tags.werkz.MavenGoalTag.runBodyTag(MavenGoalTag.java:83)
      2. org.apache.maven.jelly.tags.werkz.MavenGoalTag$MavenGoalAction.performAction(MavenGoalTag.java:116)
      3. org.apache.maven.werkz.Goal.fire(Goal.java:691)
      4. org.apache.maven.werkz.Goal.attain(Goal.java:623)
      4 frames
    11. Maven Plugin
      PluginManager.attainGoals
      1. org.apache.maven.plugin.PluginManager.attainGoals(PluginManager.java:712)
      1 frame
    12. Maven Core
      MavenSession.attainGoals
      1. org.apache.maven.MavenSession.attainGoals(MavenSession.java:265)
      1 frame
    13. M3 Interceptor
      App.main
      1. org.apache.maven.cli.App.doMain(App.java:307)
      2. org.apache.maven.cli.App.main(App.java:217)
      2 frames
    14. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:324)
      4 frames
    15. com.werken.forehead
      Forehead.main
      1. com.werken.forehead.Forehead.run(Forehead.java:551)
      2. com.werken.forehead.Forehead.main(Forehead.java:581)
      2 frames