-->
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.  [ 1 post ] 
Author Message
 Post subject: NullPointerException in DefaultFlushEntityEventListener.chec
PostPosted: Mon Sep 12, 2005 4:08 pm 
Newbie

Joined: Mon Sep 12, 2005 3:25 pm
Posts: 4
Hello,

during my tomcat startup I want to load some data form the DB into the application context. I'm approximately using the code which can be seen farther down. When I run this code, it throws the NullPointerException as can be seen below.

My debugger says that in DefaultFlushEntityEventListener.checkNaturalId, the input parameter 'loaded' is null, which should actually be an array. The entity at that point is 'Language'.

If I remove the natural-id tags from Language.hbm.xml, the exception does not occur.
And now the weird thing: If I remove the code which creates a list of 'countries', the exception also does not appear (although the exception stems from a 'Language').

I hope somebody has an idea what the problem of that listener is...
Thx
Björn

Hibernate version:
3.1 beta 2

Mapping documents:

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

<hibernate-mapping package="com.provacanza.hibernate">

<class name="Language" table="languages" mutable="false">
<meta attribute="implement-equals">true</meta>

<id name="id" type="long">
<generator class="sequence"/>
</id>
<natural-id>
<property name="iso639" type="string">
<meta attribute="use-in-equals">true</meta>
<column name="iso639" sql-type="char(2)"/>
</property>
<property name="applicationLanguage" type="string">
<meta attribute="use-in-equals">true</meta>
<column name="applicationLanguage" sql-type="char(2)"/>
</property>
</natural-id>

<property name="relevance" type="integer" not-null="true"/>
<property name="text" type="string" length="20" not-null="true"/>
</class>

</hibernate-mapping>

and

...
<class name="Country" table="countries">
<meta attribute="generated-class" inherit="false">com.provacanza.hibernate.CountryBase</meta>
<meta attribute="implement-equals">true</meta>

<id name="id" type="long">
<generator class="sequence"/>
</id>
<natural-id>
<property name="iso3166" type="string">
<meta attribute="use-in-equals">true</meta>
<column name="iso3166" sql-type="char(2)" />
</property>
</natural-id>
<property name="countryCode" type="string" length="6" />
<property name="weather" type="string" length="40" />
<set name="urls" table="country_urls">
<key column="countryId" not-null="true" />
<composite-element class="Link">
<meta attribute="generated-class" inherit="false">com.provacanza.hibernate.LinkBase</meta>
<property name="title" type="string" length="30" />
<property name="resource" type="boolean" />
<property name="url" type="string" length="40" />
</composite-element>
</set>
<set name="books" table="country_books">
<key column="countryId" />
<composite-element class="Link">
<meta attribute="generated-class" inherit="false">com.provacanza.hibernate.LinkBase</meta>
<property name="title" type="string" length="30" />
<property name="resource" type="boolean" />
<property name="url" type="string" length="40" />
</composite-element>
</set>
</class>


</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
begin tx

... (some multiple selects)
List result=session.createQuery("from Language lang where lang.applicationLanguage = :language")
.setString("language", inLanguage)
//.setString("fallback", fallbackLocale)
.list();
HashMap map = new HashMap(result.size());
Iterator it=result.iterator();
while(it.hasNext()) {
Language lang=(Language)it.next();
map.put(lang.getIso639(), lang.getText());
}

...

Session session = SessionManager.getSession();
try {
List result=session.createQuery("from Country").list();

Map map = new java.util.TreeMap();
Iterator it=result.iterator();
while(it.hasNext()) {
Country c =(Country)it.next();
map.put(c.getIso3166(), c);
}
return map;
} catch (HibernateException ex) {
throw new InfrastructureException(ex);
}

...
commit <----- here exception occurs.

Full stack trace of any exception that occurs:
SCHWERWIEGEND: Exception sending context initialized event to listener instance of class com.provacanza.listeners.ResourceManagerListener
java.lang.NullPointerException
at org.hibernate.event.def.DefaultFlushEntityEventListener.checkNaturalId(DefaultFlushEntityEventListener.java:70)
at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:145)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:97)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:870)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:344)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.provacanza.hibernate.util.SessionManager.commitTransaction(SessionManager.java:182)
at com.provacanza.hibernate.dao.LanguageDAO.finish(LanguageDAO.java:66)
at com.provacanza.beans.ApplicationLanguages.<init>(ApplicationLanguages.java:58)
at com.provacanza.listeners.ResourceManagerListener.contextInitialized(ResourceManagerListener.java:20)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3669)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4104)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:894)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:857)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:475)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1102)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:683)
at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
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 org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)

Name and version of the database you are using:
Postgres 7.4

The generated SQL (show_sql=true):
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select countrynam0_.iso3166 as col_0_0_, countrynam0_.text as col_1_0_ from countrynames countrynam0_ where countrynam0_.applicationLanguage=? or countrynam0_.applicationLanguage=? and (countrynam0_.iso3166 not in (select countrynam1_.iso3166 from countrynames countrynam1_ where countrynam1_.applicationLanguage=?))
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select countrynam0_.iso3166 as col_0_0_, countrynam0_.text as col_1_0_ from countrynames countrynam0_ where countrynam0_.applicationLanguage=? or countrynam0_.applicationLanguage=? and (countrynam0_.iso3166 not in (select countrynam1_.iso3166 from countrynames countrynam1_ where countrynam1_.applicationLanguage=?))
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select countrynam0_.iso3166 as col_0_0_, countrynam0_.text as col_1_0_ from countrynames countrynam0_ where countrynam0_.applicationLanguage=? or countrynam0_.applicationLanguage=? and (countrynam0_.iso3166 not in (select countrynam1_.iso3166 from countrynames countrynam1_ where countrynam1_.applicationLanguage=?))
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select countrynam0_.iso3166 as col_0_0_, countrynam0_.text as col_1_0_ from countrynames countrynam0_ where countrynam0_.applicationLanguage=? or countrynam0_.applicationLanguage=? and (countrynam0_.iso3166 not in (select countrynam1_.iso3166 from countrynames countrynam1_ where countrynam1_.applicationLanguage=?))
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select countrynam0_.iso3166 as col_0_0_, countrynam0_.text as col_1_0_ from countrynames countrynam0_ where countrynam0_.applicationLanguage=? or countrynam0_.applicationLanguage=? and (countrynam0_.iso3166 not in (select countrynam1_.iso3166 from countrynames countrynam1_ where countrynam1_.applicationLanguage=?))
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select language0_.id as id21_, language0_.iso639 as iso2_21_, language0_.applicationLanguage as applicat3_21_, language0_.relevance as relevance21_, language0_.text as text21_ from languages language0_ where language0_.iso639=? and language0_.applicationLanguage=?
Hibernate: select countrynam0_.iso3166 as col_0_0_, countrynam0_.text as col_1_0_ from countrynames countrynam0_ where countrynam0_.applicationLanguage=? or countrynam0_.applicationLanguage=? and (countrynam0_.iso3166 not in (select countrynam1_.iso3166 from countrynames countrynam1_ where countrynam1_.applicationLanguage=?))
Hibernate: select country0_.iso3166 as col_0_0_, country0_.countryCode as col_1_0_ from countries country0_
Hibernate: select country0_.id as id14_, country0_.iso3166 as iso2_14_, country0_.countryCode as countryC3_14_, country0_.weather as weather14_ from countries country0_

Debug level Hibernate log excerpt:
hmmmmmmm, don't know


Additional infos
My POJO code is created by hbm2java
the content of the languages and countries tables was inserted using plain sql


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.