-->
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.  [ 5 posts ] 
Author Message
 Post subject: hbm2doc and jpaconfiguration
PostPosted: Tue Nov 10, 2009 3:12 pm 
Newbie

Joined: Wed Jun 21, 2006 11:46 am
Posts: 5
Location: Research Triangle Park, NC
I'm having trouble with hbm2doc. The hbm2ddl task is working great. Here is my ant task:
Code:
    <target name="gen-ddl" description="Create ddl based on jpa annotations" depends="archive">
        <delete dir="${dist.dir}/hibernate" />
        <mkdir dir="${dist.dir}/hibernate/sql" />
        <mkdir dir="${dist.dir}/hibernate/hbmdoc"/>
       
        <hibernatetool>
           <classpath>
              <!-- it is in this classpath you put your classes dir,
                   and/or jpa persistence compliant jar -->
              <path location="${jar.dir}" />
           </classpath>
       
           <jpaconfiguration persistenceunit="classoft"  />
       
           <!-- list exporters here -->
           <hbm2ddl destdir="${dist.dir}/hibernate/sql" outputfilename="classoft-ddl.sql" drop="true" export="false" delimiter=";" format="true" />
       
           <hbm2doc destdir="${dist.dir}/hibernate/hbmdoc" />
        </hibernatetool>
    </target>


I get output like this:
Code:
[hibernatetool] 1. task: hbm2ddl (Generates database schema)
[hibernatetool] Nov 10, 2009 1:52:15 PM org.hibernate.tool.Version <clinit>
[hibernatetool] INFO: Hibernate Tools 3.2.4.GA
.
.
.
[hibernatetool] 2. task: hbm2doc (Generates html schema documentation)
[hibernatetool] An exception occurred while running exporter #3:hbm2doc (Generates html schema documentation)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.HibernateException: Could not find datasource
[hibernatetool] javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial

BUILD FAILED
/java/workJBDS200GA/classoft-ear/ant/build.xml:379: org.hibernate.HibernateException: Could not find datasource


What property do I need to set and where or do I need to create a hibernate.cfg.xml?

Thanks,
Jeff


Top
 Profile  
 
 Post subject: Re: hbm2doc and jpaconfiguration
PostPosted: Tue Nov 17, 2009 10:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
of course this should work.

try with just having hbm2doc in there - remove hbm2ddl and it might just work since it does not need access to the database - otherwise make sure your configuration is using a jdbc configuration instead of pointing to a datasource which is something that is only be available inside an application server.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: hbm2doc and jpaconfiguration
PostPosted: Wed Nov 18, 2009 5:00 pm 
Newbie

Joined: Wed Jun 21, 2006 11:46 am
Posts: 5
Location: Research Triangle Park, NC
Thanks for the help. I moved it to a separate task and had to change from jpaconfiguration to jdbcconfiguration with a hibernate.properties and a hibernate.reveng.xml to stop it from trying to look at the BIN$ tables in the oracle database. The task is completing successfully now.


Top
 Profile  
 
 Post subject: Re: hbm2doc and jpaconfiguration
PostPosted: Thu Nov 19, 2009 4:44 pm 
Newbie

Joined: Wed Jun 21, 2006 11:46 am
Posts: 5
Location: Research Triangle Park, NC
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.


Top
 Profile  
 
 Post subject: Re: hbm2doc and jpaconfiguration
PostPosted: Sun Dec 13, 2009 11:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yeah, envers does "funny" things - not sure we can do much more than you just did (i.e. not enable the envers when generating docs)

_________________
Max
Don't forget to rate


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