Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » NPE in DatabaseQueryMechanism.updateObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:978)
NPE in DatabaseQueryMechanism.updateObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:978) [message #1058006] Fri, 10 May 2013 13:13 Go to next message
Alex Panchenko is currently offline Alex PanchenkoFriend
Messages: 342
Registered: July 2009
Senior Member
Hi,

We experience the following NPE in a web application using Spring.

Caused by: java.lang.NullPointerException: null
        at org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.updateObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:978) ~[eclipselink-2.4.1.jar:2.4.1.v20121003-ad44345]
        at org.eclipse.persistence.queries.UpdateObjectQuery.executeCommitWithChangeSet(UpdateObjectQuery.java:84) ~[eclipselink-2.4.1.jar:2.4.1.v20121003-ad44345]
        at org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:286) ~[eclipselink-2.4.1.jar:2.4.1.v20121003-ad44345]
        at org.eclipse.persistence.queries.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:58) ~[eclipselink-2.4.1.jar:2.4.1.v20121003-ad44345]
        at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:852) ~[eclipselink-2.4.1.jar:2.4.1.v20121003-ad44345]
        at org.eclipse.persistence.queries.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:751) ~[eclipselink-2.4.1.jar:2.4.1.v20121003-ad44345]
        at org.eclipse.persistence.queries.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:108) ~[eclipselink-2.4.1.jar:2.4.1.v20121003-ad44345]
        at org.eclipse.persistence.queries.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:85) ~[eclipselink-2.4.1.jar:2.4.1.v20121003-ad44345]
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2875) ~[eclipselink-2.4.1.jar:2.4.1.v20121003-ad44345]
        at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1602) ~[eclipselink-2.4.1.jar:2.4.1.v20121003-ad44345]
        at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1584) ~[eclipselink-2.4.1.jar:2.4.1.v20121003-ad44345]
        at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1535) ~[eclipselink-2.4.1.jar:2.4.1.v20121003-ad44345]
        at org.eclipse.persistence.internal.sessions.CommitManager.commitChangedObjectsForClassWithChangeSet(CommitManager.java:265) ~[eclipselink-2.4.1.jar:2.4.1.v20121003-ad44345]
        at org.eclipse.persistence.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:128) ~[eclipselink-2.4.1.jar:2.4.1.v20121003-ad44345]
        at org.eclipse.persistence.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:3914) ~[eclipselink-2.4.1.jar:2.4.1.v20121003-ad44345]
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1419) ~[eclipselink-2.4.1.jar:2.4.1.v20121003-ad44345]
        at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:634) ~[eclipselink-2.4.1.jar:2.4.1.v20121003-ad44345]
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1509) ~[eclipselink-2.4.1.jar:2.4.1.v20121003-ad44345]
        at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:266) ~[eclipselink-2.4.1.jar:2.4.1.v20121003-ad44345]
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1147) ~[eclipselink-2.4.1.jar:2.4.1.v20121003-ad44345]
        at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:84) ~[eclipselink-2.4.1.jar:2.4.1.v20121003-ad44345]
        ... 73 common frames omitted


It happens via one of the controller methods and is quite reproducible. Is there a known reason and possibly a workaround for it?
How can I help identifying and fixing it?
Unfortunately it happens only on server, I was not able to reproduce it locally.

UPDATE: It seems that calling .flush() helps.

Thanks,
Alex

[Updated on: Mon, 13 May 2013 16:53]

Report message to a moderator

Re: NPE in DatabaseQueryMechanism.updateObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:978) [message #1058607 is a reply to message #1058006] Tue, 14 May 2013 14:33 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

From the code, it seems the UnitOfWork's changeSet is null. This should never be the case, so something odd is occurring.

What do you do to get the error? Is it always the same error in the same place?

Are you trying to commit the same entity-manager/transaction on multiple different threads at the same time?


James : Wiki : Book : Blog : Twitter
Re: NPE in DatabaseQueryMechanism.updateObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:978) [message #1058792 is a reply to message #1058607] Wed, 15 May 2013 07:05 Go to previous messageGo to next message
Alex Panchenko is currently offline Alex PanchenkoFriend
Messages: 342
Registered: July 2009
Senior Member
It happens in our web application using Spring Framework. Tomcat uses thread pool, but every request is handled by only one thread.

EclipseLink is accessed via EntityManager injected into controllers/services and it delegates to the instance created for the current request. Transactions are managed by Spring.

This exception was noticed in one of the controllers, however it can handle one record OK and fail on the other. The controller reads some data then creates 1 entity with some nested collections.

Exception happens if session is flushed automatically on transaction commit, but calling .flush() manually seems to help - that code path is not activated when automatic flush sees no changes.
Re: NPE in DatabaseQueryMechanism.updateObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:978) [message #1060018 is a reply to message #1058792] Wed, 22 May 2013 14:33 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Check that you have configured your transactions in Spring correctly. It seems you are getting the same EntityManager in multiple concurrent transactions.

James : Wiki : Book : Blog : Twitter
Previous Topic:Not able to create entity after changing the primary key
Next Topic:ReadallQuery alias setting
Goto Forum:
  


Current Time: Fri Apr 19 05:55:57 GMT 2024

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

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

Back to the top