I'm playing around with Hibernate and AndroMDA and while it generally works like a charm, it started throwing NullPointerException after me a few compile runs back:
Code:
19:17:15,937 ERROR Configuration:289 - Could not configure datastore from input stream
java.lang.NullPointerException
at net.sf.hibernate.util.StringHelper.qualify(StringHelper.java:241)
at net.sf.hibernate.cfg.Binder.bindCollection(Binder.java:472)
at net.sf.hibernate.cfg.Binder$2.create(Binder.java:1382)
at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:989)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:344)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1204)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:247)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:281)
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:186)
at net.sf.hibernate.cfg.Configuration.addDirectory(Configuration.java:392)
at net.sf.hibernate.cfg.Configuration.addDirectory(Configuration.java:389)
at net.sf.hibernate.cfg.Configuration.addDirectory(Configuration.java:389)
at net.sf.hibernate.cfg.Configuration.addDirectory(Configuration.java:389)
at net.sf.hibernate.cfg.Configuration.addDirectory(Configuration.java:389)
at net.sf.hibernate.cfg.Configuration.addDirectory(Configuration.java:389)
at com.triligon.addressbook.HibernateUtil.<clinit>(HibernateUtil.java:26)
at com.triligon.addressbook.Test.main(Test.java:23)
19:17:15,937 ERROR Configuration:189 - Could not configure datastore from file: .\build\hibernateservice\com\triligon\addressbook\Category.hbm.xml
net.sf.hibernate.MappingException: java.lang.NullPointerException
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:290)
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:186)
at net.sf.hibernate.cfg.Configuration.addDirectory(Configuration.java:392)
at net.sf.hibernate.cfg.Configuration.addDirectory(Configuration.java:389)
at net.sf.hibernate.cfg.Configuration.addDirectory(Configuration.java:389)
at net.sf.hibernate.cfg.Configuration.addDirectory(Configuration.java:389)
at net.sf.hibernate.cfg.Configuration.addDirectory(Configuration.java:389)
at net.sf.hibernate.cfg.Configuration.addDirectory(Configuration.java:389)
at com.triligon.addressbook.HibernateUtil.<clinit>(HibernateUtil.java:26)
at com.triligon.addressbook.Test.main(Test.java:23)
Caused by: java.lang.NullPointerException
at net.sf.hibernate.util.StringHelper.qualify(StringHelper.java:241)
at net.sf.hibernate.cfg.Binder.bindCollection(Binder.java:472)
at net.sf.hibernate.cfg.Binder$2.create(Binder.java:1382)
at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:989)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:344)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1204)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:247)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:281)
... 9 more
java.lang.ExceptionInInitializerError
at com.triligon.addressbook.Test.main(Test.java:23)
Caused by: java.lang.RuntimeException: Exception building SessionFactory: net.sf.hibernate.MappingException: java.lang.NullPointerException
at com.triligon.addressbook.HibernateUtil.<clinit>(HibernateUtil.java:29)
... 1 more
Caused by: net.sf.hibernate.MappingException: net.sf.hibernate.MappingException: java.lang.NullPointerException
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:190)
at net.sf.hibernate.cfg.Configuration.addDirectory(Configuration.java:392)
at net.sf.hibernate.cfg.Configuration.addDirectory(Configuration.java:389)
at net.sf.hibernate.cfg.Configuration.addDirectory(Configuration.java:389)
at net.sf.hibernate.cfg.Configuration.addDirectory(Configuration.java:389)
at net.sf.hibernate.cfg.Configuration.addDirectory(Configuration.java:389)
at net.sf.hibernate.cfg.Configuration.addDirectory(Configuration.java:389)
at com.triligon.addressbook.HibernateUtil.<clinit>(HibernateUtil.java:26)
... 1 more
Caused by: net.sf.hibernate.MappingException: java.lang.NullPointerException
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:290)
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:186)
... 8 more
Caused by: java.lang.NullPointerException
at net.sf.hibernate.util.StringHelper.qualify(StringHelper.java:241)
at net.sf.hibernate.cfg.Binder.bindCollection(Binder.java:472)
at net.sf.hibernate.cfg.Binder$2.create(Binder.java:1382)
at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:989)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:344)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1204)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:247)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:281)
... 9 more
Exception in thread "main"
and the mapping file is (IMHO it's correct):
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 1.1//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-1.1.dtd">
<hibernate-mapping>
<class
name="com.triligon.addressbook.Category"
table="CATEGORY"
>
<id
name="categoryID"
column="CATEGORY_I_D"
type="java.lang.String"
>
<generator class="uuid.hex">
</generator>
</id>
<discriminator
column="class"
type="string"
/>
<property
name="name"
type="java.lang.String"
>
<column
name="NAME"
sql-type="VARCHAR(255)"
/>
</property>
<set
role="people"
table="CATEGORIES_CATEGORY_I_D_PEOPLE_PERSON_I_D"
lazy="true"
readonly="false"
cascade="none"
sort="unsorted"
>
<key
column="CATEGORIES_CATEGORY_I_D"
/>
<many-to-many
class="com.triligon.addressbook.Person"
column="PEOPLE_PERSON_I_D"
outer-join="auto"
/>
</set>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Category.xml
containing the additional properties and place it in your merge dir.
-->
<subclass
name="com.triligon.addressbook.CategoryImpl"
discriminator-value="CategoryImpl"
>
</subclass>
</class>
</hibernate-mapping>
To make things even weirder, it will parse the first mapping file correctly but whichever comes next will fail (i.e. if I delete this mapping and let it go straight to the next that one will fail but work if it's all alone). I'm using addDirectory() to let hibernate pick up the mappings automatically.