-->
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.  [ 6 posts ] 
Author Message
 Post subject: hbm2java gives NullPointerException
PostPosted: Mon Apr 12, 2004 3:41 pm 
Newbie

Joined: Mon Apr 12, 2004 3:25 pm
Posts: 2
Dear All,

I am new both to java and hibernate, so maybe I overlooked something trivial. hbm2java is so new that google returns only 6 pages .-)

I am trying to generate java code from a truly minimal xbm file (see below). I also tried a couple of other xbm files downloaded from various tutorials. My command line is:

/tmp> java net.sf.hibernate.tool.hbm2java.CodeGenerator BlastHit.hbm.xml
INFO - Generating 1 in generated
java.lang.NullPointerException
at net.sf.hibernate.tool.hbm2java.BasicRenderer.isPropertySet(BasicRenderer.java:611)
at net.sf.hibernate.tool.hbm2java.BasicRenderer.generateConcreteEmptyClasses(BasicRenderer.java:332)
at net.sf.hibernate.tool.hbm2java.BasicRenderer.render(BasicRenderer.java:59)
at net.sf.hibernate.tool.hbm2java.Generator.write(Generator.java:138)
at net.sf.hibernate.tool.hbm2java.Generator.writeRecur(Generator.java:115)
at net.sf.hibernate.tool.hbm2java.Generator.generate(Generator.java:104)
at net.sf.hibernate.tool.hbm2java.CodeGenerator.main(CodeGenerator.java:125)

The file BlastHit.java is created but contains zero bytes. What I am doing wrong?

Any help will be greatly appreciated.

Dmitrij

------------ BlastHit.hbm.xml --------------------

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class name="BlastHit" table="blast">
<id name="id" type="long">
<generator class="increment"/>
</id>
<property name="code" type="string" column="code"/>
</class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 12, 2004 5:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
arh darn - i've found the bug in the default configuration of hbmj2ava ;(

if you use the --config option then there should be no problems

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 12, 2004 5:51 pm 
Newbie

Joined: Mon Apr 12, 2004 3:25 pm
Posts: 2
max wrote:
arh darn - i've found the bug in the default configuration of hbmj2ava ;(

if you use the --config option then there should be no problems


Thank you, max. I tried it, but unfortunately it did not help:

/tmp> java net.sf.hibernate.tool.hbm2java.CodeGenerator --config BlastHit.hbm.xml
INFO - Generating 1 in generated
java.lang.NullPointerException
at net.sf.hibernate.tool.hbm2java.BasicRenderer.isPropertySet(BasicRenderer.java:611)
at net.sf.hibernate.tool.hbm2java.BasicRenderer.generateConcreteEmptyClasses(BasicRenderer.java:332)
at net.sf.hibernate.tool.hbm2java.BasicRenderer.render(BasicRenderer.java:59)
at net.sf.hibernate.tool.hbm2java.Generator.write(Generator.java:138)
at net.sf.hibernate.tool.hbm2java.Generator.writeRecur(Generator.java:115)
at net.sf.hibernate.tool.hbm2java.Generator.generate(Generator.java:104)
at net.sf.hibernate.tool.hbm2java.CodeGenerator.main(CodeGenerator.java:125)

Any other suggestions?

Regards,
Dmitrij


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 12, 2004 6:04 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
read the docs about --config. it neat's a hbm2java config file as input!

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: hbm2java null pointer (+ant task)
PostPosted: Mon Apr 12, 2004 6:16 pm 
Newbie

Joined: Fri Feb 27, 2004 6:17 pm
Posts: 11
I just ran into this one as well. I used the default config.xml at http://www.hibernate.org/hib_docs/reference/html/toolsetguide.html#toolsetguide-s2-1

I named it hbm2java_config.xml.

I just went looking through the docs, and I didn't realize that there was an Ant task for hbm2java. Was this a recent addition? Very nice...

Since I had to touch this stuff anyways to put in the config element, I went ahead and switched to the Ant task (instead of just calling the hbm2java main from my build.xml).

Here it is, in case anyone finds it useful. :)


Code:
<target name="build_hbm" description="builds the Java sources">
   <mkdir dir="${build.src.dir}"/>
   <echo message="src dir = ${build.src.dir}"/>
   <echo message="target hbm files = ${build.hbm.dir}${package.dir}\" />

   <taskdef name="hbm2java"
       classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask">
      <classpath>
         <pathelement
            location="${hibernate_path}\hibernate2.jar"/>
         <pathelement
         location="${hibernate_tool_path}\hibernate-tools.jar"/>
         <pathelement
         location="${hibernate_path}\lib\commons-collections-2.1.jar" />
         <pathelement
         location="${hibernate_path}\lib\commons-logging-1.0.3.jar" />
         <pathelement
         location="${hibernate_path}\lib\commons-lang-1.0.1.jar" />
         <pathelement location="${hibernate_path}\lib\xerces-2.4.0.jar" />
         <pathelement location="${hibernate_tool_path}\lib\jdom.jar"/>
      </classpath>
   </taskdef>

   <hbm2java config="hbm2java_config.xml" output="${build.src.dir}">
      <fileset dir="${build.hbm.dir}${package.dir}" includes="*.hbm.xml"/>
   </hbm2java>
</target>


Top
 Profile  
 
 Post subject: hbm2java config file
PostPosted: Mon Apr 12, 2004 6:18 pm 
Newbie

Joined: Fri Feb 27, 2004 6:17 pm
Posts: 11
dmitrij - the hbm2java config file isn't an hbm.xml file, it's a different XML file (per the docs).


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