Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » ConcurrentModificationException in query execution(upgraded eclipselink from 2.2.0 to 2.7.7 and migrated to Java 11)
ConcurrentModificationException in query execution [message #1832426] Thu, 17 September 2020 15:48 Go to next message
Michael Earl is currently offline Michael EarlFriend
Messages: 3
Registered: September 2020
Junior Member
We upgraded from Java 8 to Java 11 and from EclipseLink 2.2.0 to 2.7.7 and now we are getting ConcurrentModificationException on some of our queries. Our code has not changed with the Java and EclipseLink library upgrades. Also, this is not an issue with sharing EntityManager's between threads as I single threaded all queries and I still get the same issues. Also, this does not occur on all entity queries but seems to be isolated to a few Entities with OneToMany and ManyToOne relationships. Also, when the OneToMany side of the releationship is removed from the problematic Entities, the problem for that Entities goes away. For instance I removed the following OneToMany relationship to SiteHost: but kept the ManyToOne side of the relationship.

@Entity
@Table( name = "TOUCHSCREEN_TYPE" )
public class TouchscreenType extends AbstractDataModel<TouchscreenType> implements Serializable
{
private static final long serialVersionUID = 1L;
@Id
@Column( name = "TOUCHSCREEN_TYPE_ID" )
private int touchscreenTypeId;
@Column( name = "MANUFACTURER_NAME" )
private String manufacturerName;
@Column( name = "MOUSE_ACTION_TYPE" )
private String mouseActionType;
//bi-directional many-to-one association to ipAddress
@OneToMany( mappedBy = "touchscreenType" )
private Set<SiteHost> siteHosts;

-- other side of the relationship
// bi-directional many-to-one association to TouchscreenType
@ManyToOne
@JoinColumn( name = "TOUCHSCREEN_TYPE_ID" )
private TouchscreenType touchscreenType;

----------------------Exception--------------------------
java.util.ConcurrentModificationException: null
at java.util.HashMap$HashIterator.nextNode(HashMap.java:1493) ~[?:?]
at java.util.HashMap$KeyIterator.next(HashMap.java:1516) ~[?:?]
at org.eclipse.persistence.indirection.IndirectSet$1.next(IndirectSet.java:523) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.queries.InterfaceContainerPolicy.next(InterfaceContainerPolicy.java:303) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.queries.ContainerPolicy.next(ContainerPolicy.java:1180) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.mappings.CollectionMapping.buildExpression(CollectionMapping.java:369) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildExpressionFromExample(ObjectBuilder.java:659) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.mappings.CollectionMapping.buildExpression(CollectionMapping.java:371) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildExpressionFromExample(ObjectBuilder.java:659) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.mappings.ObjectReferenceMapping.buildExpression(ObjectReferenceMapping.java:194) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildExpressionFromExample(ObjectBuilder.java:659) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.mappings.CollectionMapping.buildExpression(CollectionMapping.java:371) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildExpressionFromExample(ObjectBuilder.java:659) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.mappings.CollectionMapping.buildExpression(CollectionMapping.java:373) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildExpressionFromExample(ObjectBuilder.java:659) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.mappings.ObjectReferenceMapping.buildExpression(ObjectReferenceMapping.java:194) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildExpressionFromExample(ObjectBuilder.java:659) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.mappings.CollectionMapping.buildExpression(CollectionMapping.java:371) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildExpressionFromExample(ObjectBuilder.java:659) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.mappings.ObjectReferenceMapping.buildExpression(ObjectReferenceMapping.java:194) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildExpressionFromExample(ObjectBuilder.java:659) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.mappings.CollectionMapping.buildExpression(CollectionMapping.java:373) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildExpressionFromExample(ObjectBuilder.java:659) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.mappings.ObjectReferenceMapping.buildExpression(ObjectReferenceMapping.java:194) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildExpressionFromExample(ObjectBuilder.java:659) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.mappings.CollectionMapping.buildExpression(CollectionMapping.java:371) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildExpressionFromExample(ObjectBuilder.java:659) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.mappings.ObjectReferenceMapping.buildExpression(ObjectReferenceMapping.java:194) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildExpressionFromExample(ObjectBuilder.java:659) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.mappings.CollectionMapping.buildExpression(CollectionMapping.java:371) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildExpressionFromExample(ObjectBuilder.java:659) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.mappings.ObjectReferenceMapping.buildExpression(ObjectReferenceMapping.java:194) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildExpressionFromExample(ObjectBuilder.java:659) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.queries.QueryByExampleMechanism.buildSelectionCriteria(QueryByExampleMechanism.java:80) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.queries.DatabaseQuery.buildSelectionCriteria(DatabaseQuery.java:544) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.queries.ObjectLevelReadQuery.prePrepare(ObjectLevelReadQuery.java:2152) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.queries.ObjectLevelReadQuery.checkPrePrepare(ObjectLevelReadQuery.java:985) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.queries.ObjectLevelReadQuery.checkEarlyReturn(ObjectLevelReadQuery.java:910) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:848) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1191) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:485) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1279) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2983) ~[eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1898) [eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1880) [eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1845) [eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:262) [eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:482) [eclipselink.jar:2.7.7.v20200504-69f2c2b80d]
Re: ConcurrentModificationException in query execution [message #1832471 is a reply to message #1832426] Fri, 18 September 2020 13:26 Go to previous messageGo to next message
Michael Earl is currently offline Michael EarlFriend
Messages: 3
Registered: September 2020
Junior Member
Additional information. We are using the following query hints:

query.setHint( QueryHints.REFRESH, HintValues.TRUE );
query.setHint( QueryHints.REFRESH_CASCADE, CascadePolicy.CascadeAllParts );

I tried EclipseLink 2.7.8 and 3.0.0 and the issue persists.

[Updated on: Fri, 18 September 2020 13:28]

Report message to a moderator

Re: ConcurrentModificationException in query execution [message #1832609 is a reply to message #1832471] Mon, 21 September 2020 20:17 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1388
Registered: July 2009
Senior Member
That is a lot of changes from when it was 'working' to now. Key in the stack though is that it has ObjectBuilder.buildExpressionFromExample, indicating this is a query by example query. As you are getting a concurrent modification exception on IndirectSet, I would guess you are passing something into the query that is shared, and so not thread safe for concurrent access.

Check your application that you are not passing something from the shared cache to your query (a read-only instance perhaps) when some other processes might have changes being merged into it.
Re: ConcurrentModificationException in query execution [message #1832648 is a reply to message #1832609] Tue, 22 September 2020 15:20 Go to previous message
Michael Earl is currently offline Michael EarlFriend
Messages: 3
Registered: September 2020
Junior Member
Thanks for the response Chris. You are correct, we are using QBE and the query is being performed by the JPA entity. I'll have to think about your advice. I
Previous Topic:Package org.eclipse.persistence.internal.libraries.asm not found building EclipseLink 2.7.0
Next Topic:Eclipselink - dead locks in aqcuire and release deferred locks - Eclipselink 2.4.2 and above
Goto Forum:
  


Current Time: Tue Jun 22 14:24:19 GMT 2021

Powered by FUDForum. Page generated in 0.02279 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top