-->
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.  [ 8 posts ] 
Author Message
 Post subject: problem with a null pointer in AbstractEntityTuplizer
PostPosted: Fri Oct 14, 2005 3:34 pm 
Newbie

Joined: Wed Dec 08, 2004 1:58 pm
Posts: 7
This code was working in version 2 of Hibernate. Upon upgrading I get this very hard to trace error bellow. If I comment out this mapping it seems to go away
Hibernate version: 3.1

Mapping documents:
from PossibleSampleTime.hbm.xml
<set
name="schedSampleTimes"
lazy="false"
inverse="true"
cascade="all-delete-orphan">
<key column="SST_SMPT_ID"/>
<one-to-many class="com.xxxx.protocol.model.SchedSampleTime"/>

from SchedSampleTime.hbm.xml

<many-to-one
name="possibleSampleTime"
class="com.xxxx.protocol.model.PossibleSampleTime"
column="SST_SMPT_ID"
not-null="true"
/>
</set>



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

Full stack trace of any exception that occurs:
java.lang.NullPointerException
at org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3120)
at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:232)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:173)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:781)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:753)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)
at org.hibernate.type.EntityType.resolve(EntityType.java:303)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:113)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:223)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1916)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:71)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:520)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1565)
at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:454)
at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:791)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:228)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1782)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2729)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:781)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:753)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)
at org.hibernate.type.EntityType.resolve(EntityType.java:303)
at org.hibernate.type.EntityType.nullSafeGet(EntityType.java:217)
at org.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:93)
at org.hibernate.impl.IteratorImpl.<init>(IteratorImpl.java:58)
at org.hibernate.loader.hql.QueryLoader.iterate(QueryLoader.java:386)
at org.hibernate.hql.ast.QueryTranslatorImpl.iterate(QueryTranslatorImpl.java:306)
at org.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1083)
at org.hibernate.impl.QueryImpl.iterate(QueryImpl.java:41)
at com.celera.protocol.model.MetaDMPKStudy.findById(MetaDMPKStudy.java:172)
at com.celera.protocol.model.MetaDMPKStudy.main(MetaDMPKStudy.java:421)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 14, 2005 3:44 pm 
Beginner
Beginner

Joined: Tue Aug 16, 2005 11:06 pm
Posts: 46
Try replace

<key column="SST_SMPT_ID"/>

with

<key column="SST_SMPT_ID" not-null= "true"/>


Hope it is helpful.

_________________
Jason Li
Don't forget to rate:)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 14, 2005 4:08 pm 
Newbie

Joined: Wed Dec 08, 2004 1:58 pm
Posts: 7
I still get the error. It seems to be related to having the same object being used as a set in two different objects. The ReplicateGroup has a set of SchedSampleTime's. The PossibleSampleTime also has a set of SchedSampleTime's. When I comment out the relationship in one the other one will work. I use the ReplicateGroup to save the records but the I want the PossibleSampleTimes used to just query them up. Perhaps there is a better way to map this?

Thanks in advance for any suggestions

Dan


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 28, 2005 10:46 pm 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
I am seeing this same behavior in 3.1rc3. Did you ever figure it out? If not I will try to trace to get more detail and file a bug if required. I believe it has something to do with the class-level lazy loading changes that happened from 2.x to 3.x.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 28, 2005 11:17 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
yes, if you can reproduce this in an isolated bundle please file a bug report in jira attaching said bundle.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 9:49 am 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
Of course it is not a bug in Hibernate. For anyone who runs into this in the future -- it is due to the class lazy loading becoming the default in Hibernate 3.x - I didn't have some required dependencies (org.objectweb.asm) for CGLIB. I had also disabled even error logging for hibernate while running my unit tests. Once I enabled logging (org.hibernate.tuple), I saw the obvious problem:

Code:
Caused by: java.lang.NoClassDefFoundError
   at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
   at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:116)
   ... 25 more


This causes buildProxyFactory in PojoEntityTuplizer to return null, thus the later getProxyFactory call when we are actually getting the proxy for the class fails with an NPE.

While the NPE isn't pretty, IMHO I don't think it's really a bug because the behavior of the class has to be undefined if there is an unexpected failure.

I think I will file an enhancement request that -if- there is an error in setting up the CGLIB stuff (proxy factory is unavailable) the class lazy loading behavior will flip back to lazy="false". That seems like a reasonable solution - anyone have an opinion to the contrary?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 9:50 am 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
To be clear -- this isn't a bug caused by the move to HHH, simply that I wasn't using CGLIB in Hibernate 2 and foolishly ignored some of the dependencies that CGLIB has. If I just copied all the third-party stuff in Hibernate/lib into my classpath, I would never have seen this error (and I'd assume that the OP wouldn't either).


Top
 Profile  
 
 Post subject: So what are the dependencies you missed?
PostPosted: Tue Jan 17, 2006 3:15 pm 
Newbie

Joined: Wed Dec 21, 2005 4:03 pm
Posts: 11
Location: Pittsburgh
Like bcel.zip?

I have exactly the same problem you have.


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