Max, you said it should work with a jpaconfiguration and so I went back today and played around with it some more. I think it is working but that because we are using Envers, it is having problems with the auditing entities. I think the hbm2doc process is expecting to find actual java classes for the Envers-created entities. For example, we have an UserAccount class. I ran ant with -verbose and got the stack trace and found it complaining about not finding a UserAccount_AUD entity. Should this be a jira issue perhaps?
I noticed this in the stack trace:
Code:
Caused by: freemarker.template.TemplateModelException: Method public java.lang.String org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.getShortName() threw an exception when invoked on Entity: com.terida.classoft.entity.user.UserAccount_AUD
Here is the full stack trace I got back:
Code:
BUILD FAILED
/java/workJBDS200GA/classoft-ear/ant/build.xml:397: org.hibernate.tool.hbm2x.ExporterException: Error while processing Unknown context with template doc/entities/entity.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.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.Main.runBuild(Main.java:698)
at org.apache.tools.ant.Main.startAnt(Main.java:199)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: org.hibernate.tool.hbm2x.ExporterException: Error while processing Unknown context with template doc/entities/entity.ftl
at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:261)
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.DocExporter.processTemplate(DocExporter.java:614)
at org.hibernate.tool.hbm2x.DocExporter.generateEntitiesDetails(DocExporter.java:436)
at org.hibernate.tool.hbm2x.DocExporter.doStart(DocExporter.java:162)
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)
... 16 more
Caused by: freemarker.template.TemplateModelException: Method public java.lang.String org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.getShortName() threw an exception when invoked on Entity: com.terida.classoft.entity.user.UserAccount_AUD
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.Environment.process(Environment.java:176)
at freemarker.template.Template.process(Template.java:232)
at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:255)
... 25 more
Caused by: java.lang.NullPointerException
at org.hibernate.util.StringHelper.unqualify(StringHelper.java:150)
at org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.getShortName(BasicPOJOClass.java:90)
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 freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:616)
at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:113)
... 35 more
--- Nested Exception ---
org.hibernate.tool.hbm2x.ExporterException: Error while processing Unknown context with template doc/entities/entity.ftl
at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:261)
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.DocExporter.processTemplate(DocExporter.java:614)
at org.hibernate.tool.hbm2x.DocExporter.generateEntitiesDetails(DocExporter.java:436)
at org.hibernate.tool.hbm2x.DocExporter.doStart(DocExporter.java:162)
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)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.Main.runBuild(Main.java:698)
at org.apache.tools.ant.Main.startAnt(Main.java:199)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: freemarker.template.TemplateModelException: Method public java.lang.String org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.getShortName() threw an exception when invoked on Entity: com.terida.classoft.entity.user.UserAccount_AUD
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.Environment.process(Environment.java:176)
at freemarker.template.Template.process(Template.java:232)
at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:255)
... 25 more
Caused by: java.lang.NullPointerException
at org.hibernate.util.StringHelper.unqualify(StringHelper.java:150)
at org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.getShortName(BasicPOJOClass.java:90)
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 freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:616)
at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:113)
... 35 more
Update: I switch the taskdef classname from
org.hibernate.tool.ant.EnversHibernateToolTask to
org.hibernate.tool.ant.HibernateToolTask and hbm2doc completes successfully. I just don't have any information about the audit entities and tables.