Modification Exception JBAS018845 if a relation (CMP) of an EJB2-CMP EntityBean is used in EAP6

Solution Verified - Updated -

Issue

After migration of an EJB2 application to EAP6 an Exception is thrown if we use an Iterator to modify the relation.

javax.ejb.EJBException: java.lang.IllegalStateException: JBAS018845: Underlying collection has been modified
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:165) 
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:229) 
at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:303) 
at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:189) 

In former EAP versions this code snipped will work:

Collection c = myEntity.getRelatedEntity(); //use the 1-n relation to get the collection of related Entities
Iterator iter = c.iterator();
while(iter.hasNext())
{
    ReleatedEntity r = (ReleatedEntity) iter.next();
    r.remove(); //deletion of related bean
}

Environment

  • JBoss Enterprise Application Server (EAP) 6

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