-->
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.  [ 5 posts ] 
Author Message
 Post subject: ConcurrentModificationException while updating entity
PostPosted: Fri Oct 16, 2009 7:38 am 
Newbie

Joined: Fri Oct 16, 2009 7:12 am
Posts: 3
Hi there,

I searched the forum for a similar issue and i found many topics about ConcurrentModificationExceptions, but haven't found anything related. So I make up a new topic on our problem using hibernate. We get this exception not every time, it happens after updating about 50k entities and cannot exactly be reproduced.
The stacktrace shows an Exception deep inside hibernate and I hope there is anybody who can tell me something we can do in this case.

We use Hibernate Version 3.2.7 without 2nd level cache and annotations, configured by hbm.xml files. Java Runtime is 1.6.0 Update 10.

Code:
java.util.ConcurrentModificationException
    at org.apache.commons.collections.ReferenceMap$EntryIterator.checkMod(Unknown Source)
    at org.apache.commons.collections.ReferenceMap$EntryIterator.hasNext(Unknown Source)
    at java.util.AbstractMap.containsValue(Unknown Source)
    at org.hibernate.engine.StatefulPersistenceContext.containsProxy(StatefulPersistenceContext.java:467)
    at org.hibernate.proxy.AbstractLazyInitializer.isConnectedToSession(AbstractLazyInitializer.java:141)
    at org.hibernate.proxy.AbstractLazyInitializer.setSession(AbstractLazyInitializer.java:85)
    at org.hibernate.engine.StatefulPersistenceContext.reassociateProxy(StatefulPersistenceContext.java:525)
    at org.hibernate.engine.StatefulPersistenceContext.reassociateIfUninitializedProxy(StatefulPersistenceContext.java:485)
    at org.hibernate.event.def.ProxyVisitor.processEntity(ProxyVisitor.java:27)
    at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:104)
    at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:61)
    at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:55)
    at org.hibernate.event.def.AbstractVisitor.process(AbstractVisitor.java:123)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:293)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:223)
    at org.hibernate.event.def.DefaultUpdateEventListener.performSaveOrUpdate(DefaultUpdateEventListener.java:33)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
    at org.hibernate.impl.SessionImpl.fireUpdate(SessionImpl.java:565)
    at org.hibernate.impl.SessionImpl.update(SessionImpl.java:553)
    at org.hibernate.impl.SessionImpl.update(SessionImpl.java:545)
    at com.desoft.std.dao.hibernate.BaseHibernateDAO$1.execute(BaseHibernateDAO.java:87)

I can post more information on this topic by demand, feel free to ask!

Thanks in advance,
Florian Probst


Top
 Profile  
 
 Post subject: Re: ConcurrentModificationException while updating entity
PostPosted: Fri Oct 16, 2009 8:10 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
it happens after updating about 50k entities and cannot exactly be reproduced.

Only after that number? Using the same Session?
Did you try clearing the Session periodically? I'm not saying that is the solution, but I'm wondering if this is triggered by having more than that number of objects in session. For memory management you're supposed to clear the session periodically in batch processing.

Could you try reproducing the problem on an updated Hibernate version like 3.3.2 ? Would be useful to report the issue in JIRA.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: ConcurrentModificationException while updating entity
PostPosted: Fri Oct 16, 2009 8:53 am 
Newbie

Joined: Fri Oct 16, 2009 7:12 am
Posts: 3
First, thanks for your answer, Sanne!

The 50k means overall. These entities are not in the same session. For each update a new session is used but the updates are very frequently on the same entity.
In this cenario we have two threads. The first is reading cyclic entities from one table in the database. Before each select the session is cleared(). The other thread does the update on specific entities. The objects are evicted and merged form one session to the other.

I don't know if an update to Hibernate 3.3.2 is possible without problems, we will try...


Top
 Profile  
 
 Post subject: Re: ConcurrentModificationException while updating entity
PostPosted: Wed Jan 13, 2016 3:36 am 
Hello.
Its an old thead, but It is the exact scenario i am facing in my application and found nothing on forums. Have you (or any body for that matter) found any clue what was the reason and/or fix or any possible workaround?
I am using hibernate-3.2.3 in my application.
Here is the stacktrace:
Code:
java.util.ConcurrentModificationException
   at org.apache.commons.collections.ReferenceMap$EntryIterator.checkMod(ReferenceMap.java:865) [commons-collections-3.2.jar:3.2]
   at org.apache.commons.collections.ReferenceMap$EntryIterator.hasNext(ReferenceMap.java:840) [commons-collections-3.2.jar:3.2]
   at java.util.AbstractMap.containsValue(AbstractMap.java:117) [rt.jar:1.7.0_65]
   at org.hibernate.engine.StatefulPersistenceContext.containsProxy(StatefulPersistenceContext.java:455) [hibernate-3.2.3.ga.jar:3.2.3.ga]
   at org.hibernate.proxy.AbstractLazyInitializer.isConnectedToSession(AbstractLazyInitializer.java:97) [hibernate-3.2.3.ga.jar:3.2.3.ga]
   at org.hibernate.proxy.AbstractLazyInitializer.setSession(AbstractLazyInitializer.java:86) [hibernate-3.2.3.ga.jar:3.2.3.ga]
   at org.hibernate.engine.StatefulPersistenceContext.reassociateProxy(StatefulPersistenceContext.java:513) [hibernate-3.2.3.ga.jar:3.2.3.ga]
   at org.hibernate.engine.StatefulPersistenceContext.reassociateIfUninitializedProxy(StatefulPersistenceContext.java:473) [hibernate-3.2.3.ga.jar:3.2.3.ga]
   at org.hibernate.event.def.ProxyVisitor.processEntity(ProxyVisitor.java:27) [hibernate-3.2.3.ga.jar:3.2.3.ga]
   at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:104) [hibernate-3.2.3.ga.jar:3.2.3.ga]
   at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:61) [hibernate-3.2.3.ga.jar:3.2.3.ga]
   at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:55) [hibernate-3.2.3.ga.jar:3.2.3.ga]
   at org.hibernate.event.def.AbstractVisitor.process(AbstractVisitor.java:123) [hibernate-3.2.3.ga.jar:3.2.3.ga]
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:293) [hibernate-3.2.3.ga.jar:3.2.3.ga]
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:223) [hibernate-3.2.3.ga.jar:3.2.3.ga]
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:89) [hibernate-3.2.3.ga.jar:3.2.3.ga]
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) [hibernate-3.2.3.ga.jar:3.2.3.ga]
   at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) [hibernate-3.2.3.ga.jar:3.2.3.ga]
   at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) [hibernate-3.2.3.ga.jar:3.2.3.ga]
   at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:495) [hibernate-3.2.3.ga.jar:3.2.3.ga]
   at org.springframework.orm.hibernate3.HibernateTemplate$16.doInHibernate(HibernateTemplate.java:740) [org.springframework.orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406) [org.springframework.orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374) [org.springframework.orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:737) [org.springframework.orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]


Thanks in advance.


Top
  
 
 Post subject: Re: ConcurrentModificationException while updating entity
PostPosted: Tue Feb 14, 2017 2:34 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi, version hibernate-3.2.3 is 10 years old!

This problem was very likely already fixed in one of the more than ten thousand patches people have been applying since then? Sorry, I'm not going to try figuring out which change it might be, I hope you understand ;-)

Please upgrade, it will solve this problem and many more issues you don't know about yet.

_________________
Sanne
http://in.relation.to/


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