[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5599) NPE occurs when using Infinispan as L2 Cache

Galder Zamarreno (JIRA) noreply at atlassian.com
Mon Oct 18 12:25:48 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5599?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=38791#action_38791 ] 

Galder Zamarreno commented on HHH-5599:
---------------------------------------

Chris, the code where this is coming from is relatively complex and so it's not a straightforward thing to figure out what the cause is, and whether the cause is a valid one and should protect against, or whether instead is a bug somewhere else in the code.

Unfortunately, there's not much logging in this area, so I don't think it'd help much unless it can clarify the following doubt I have: 

Are you accessing Hibernate within transactions or not? If you're using transactions, what type of transactions and which is the transaction manager that you're using? Can you attach your hibernate configuration file? 

Also, if you're using transactions, I'd like to understand the flow of transactions and whether a particular transaction can be accessed by different threads.

Based on what I've seen, a particular key can either be cleaned up:

a) This is materially impossible but by the same thread twice a row. I can't see how this can happen cos the same thread, concurrently would need to call one of the operations that can cleanup the pending map. 

b) By the same transaction twice in a row. Now, if your transactions can span multiple threads, two parts of the same transaction might be calling clean up of the same key and since their transaction would be the same, this could be a possibility. 

> NPE occurs when using Infinispan as L2 Cache
> --------------------------------------------
>
>                 Key: HHH-5599
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5599
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: caching (L2)
>    Affects Versions: 3.5.5, 3.5.6
>         Environment: Hib 3.5.6
> Infinispan 4.2.0.ALPHA2
> (same thing happen with Hib 3.5.5 and IS 4.1.0.FINAL)
>            Reporter: Chris
>            Assignee: Galder Zamarreno
>            Priority: Critical
>
> Pretty much randomly or so it seems, infinispan hibernate layer will throw a NPE. It occurs a lot when the j2EE server is started and overtime (once caches are warmer?) diminish.
> The issue comes from the PutFromLoadValidator.Java(565).The cleaned element is null and the map.put(cleaned) fails since the key is coming from the cleaned element (cleaned.owner).
> Complete stacktraces, the first on entity loading and the later on collection loading:
> Cause: java.lang.NullPointerException
>     at org.hibernate.cache.infinispan.access.PutFromLoadValidator$PendingPut.access$700(PutFromLoadValidator.java:674)
>     at org.hibernate.cache.infinispan.access.PutFromLoadValidator$PendingPutMap.put(PutFromLoadValidator.java:627)
>     at org.hibernate.cache.infinispan.access.PutFromLoadValidator.cleanOutdatedPendingPuts(PutFromLoadValidator.java:565)
>     at org.hibernate.cache.infinispan.access.PutFromLoadValidator.preventOutdatedPendingPuts(PutFromLoadValidator.java:493)
>     at org.hibernate.cache.infinispan.access.PutFromLoadValidator.registerPendingPut(PutFromLoadValidator.java:438)
>     at org.hibernate.cache.infinispan.access.TransactionalAccessDelegate.get(TransactionalAccessDelegate.java:66)
>     at org.hibernate.cache.infinispan.entity.TransactionalAccess.get(TransactionalAccess.java:36)
>     at org.hibernate.engine.BatchFetchQueue.isCached(BatchFetchQueue.java:278)
>     at org.hibernate.engine.BatchFetchQueue.getEntityBatch(BatchFetchQueue.java:253)
>     at org.hibernate.loader.entity.BatchingEntityLoader.load(BatchingEntityLoader.java:90)
>     at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3270)
>     at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:496)
>     at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:477)
>     at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227)
>     at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:285)
>     at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
>     at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1080)
>     at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1028)
>     at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:623)
>     at org.hibernate.type.EntityType.resolve(EntityType.java:431)
>     at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:140)
>     at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:898)
>     at org.hibernate.loader.Loader.doQuery(Loader.java:773)
>     at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270)
>     at org.hibernate.loader.Loader.loadEntityBatch(Loader.java:2047)
>     at org.hibernate.loader.entity.BatchingEntityLoader.load(BatchingEntityLoader.java:99)
>     at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3270)
>     at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:496)
>     at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:477)
>     at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227)
>     at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:285)
>     at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
>     at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1080)
>     at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1028)
>     at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:623)
>     at org.hibernate.type.EntityType.resolve(EntityType.java:431)
>     at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:140)
>     at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:898)
>     at org.hibernate.loader.Loader.doQuery(Loader.java:773)
>     at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270)
>     at org.hibernate.loader.Loader.doList(Loader.java:2449)
>     at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2192)
>     at org.hibernate.loader.Loader.list(Loader.java:2187)
>     at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452)
>     at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
>     at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
>     at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1258)
>     at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
> Cause: java.lang.NullPointerException
>     at org.hibernate.cache.infinispan.access.PutFromLoadValidator$PendingPut.access$700(PutFromLoadValidator.java:674)
>     at org.hibernate.cache.infinispan.access.PutFromLoadValidator$PendingPutMap.put(PutFromLoadValidator.java:627)
>     at org.hibernate.cache.infinispan.access.PutFromLoadValidator.cleanOutdatedPendingPuts(PutFromLoadValidator.java:565)
>     at org.hibernate.cache.infinispan.access.PutFromLoadValidator.preventOutdatedPendingPuts(PutFromLoadValidator.java:493)
>     at org.hibernate.cache.infinispan.access.PutFromLoadValidator.registerPendingPut(PutFromLoadValidator.java:438)
>     at org.hibernate.cache.infinispan.access.TransactionalAccessDelegate.get(TransactionalAccessDelegate.java:66)
>     at org.hibernate.cache.infinispan.collection.TransactionalAccess.get(TransactionalAccess.java:36)
>     at org.hibernate.engine.BatchFetchQueue.isCached(BatchFetchQueue.java:295)
>     at org.hibernate.engine.BatchFetchQueue.getCollectionBatch(BatchFetchQueue.java:203)
>     at org.hibernate.loader.collection.BatchingCollectionInitializer.initialize(BatchingCollectionInitializer.java:73)
>     at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:628)
>     at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:83)
>     at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1853)
>     at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:479)
>     at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:899)
>     at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:275)
>     at org.hibernate.loader.Loader.doList(Loader.java:2449)
>     at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2192)
>     at org.hibernate.loader.Loader.list(Loader.java:2187)
>     at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452)
>     at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
>     at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
>     at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1258)
>     at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
> For now I am masking this class with my own which essentially is a copy and paste but added a null check before trying to put back the element.
> How the big question is : Is it normal that the element can be null and it's a simple null check that has been forgotten or the element should never be null and something bigger is going on ?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list