Why application throws 'java.util.ConcurrentModificationException' while performing a Hibernate action ?

Solution Verified - Updated -

Issue

  • Why I'm getting java.util.ConcurrentModificationException in EAP 5.1 when using "Test Runner" and performing hibernate query ?
Caused by: java.util.ConcurrentModificationException
    at java.util.LinkedHashMap$LinkedHashIterator.nextEntry(LinkedHashMap.java:373)
    at java.util.LinkedHashMap$EntryIterator.next(LinkedHashMap.java:392)
    at java.util.LinkedHashMap$EntryIterator.next(LinkedHashMap.java:391)
    at org.hibernate.util.IdentityMap.entryArray(IdentityMap.java:228)
    at org.hibernate.util.IdentityMap.concurrentEntries(IdentityMap.java:89)
    at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:136)
    at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:88)
    at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:58)
    at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:998)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1143)
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
    at com.aaa.bbb.server.persistence.dao.CshAggValueDAOBean.findSODValues(CshAggValueDAOBean.java:210)
    at com.aaa.bbb.server.persistence.facade.PersistenceFacadeEJB.getSODAggValueByFundAndEffDate(PersistenceFacadeEJB.java:872)
    ... 129 more
  • In EAP 6.0, Why application is throwing java.util.ConcurrentModificationException for entity update when trying to do hibernate conditional auditing which depends on database flag? The EJB bean which does the auditing and the bean which determines the conditional flag shares same persistence unit.
Caused by: java.util.ConcurrentModificationException
    at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:859) [rt.jar:1.7.0_45]
    at java.util.ArrayList$Itr.next(ArrayList.java:831) [rt.jar:1.7.0_45]
    at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:353) [hibernate-core-4.1.6.Final-redhat-3.jar:4.1.6.Final-redhat-3]
    at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:276) [hibernate-core-4.1.6.Final-redhat-3.jar:4.1.6.Final-redhat-3]
    at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:326) [hibernate-core-4.1.6.Final-redhat-3.jar:4.1.6.Final-redhat-3]
    at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52) [hibernate-core-4.1.6.Final-redhat-3.jar:4.1.6.Final-redhat-3]
    at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1214) [hibernate-core-4.1.6.Final-redhat-3.jar:4.1.6.Final-redhat-3]
    at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:403) [hibernate-core-4.1.6.Final-redhat-3.jar:4.1.6.Final-redhat-3]
    at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.beforeCompletion(SynchronizationCallbackCoordinatorImpl.java:104) [hibernate-core-4.1.6.Final-redhat-3.jar:4.1.6.Final-redhat-3]
    ... 40 more

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 5.1.0
    • 6.0.1
  • Hibernate
    • 3.3.2.GA_CP03
    • 4.1

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.