1

Unlike What is a NullPointerException, and how do I fix it? I'm searching for reason why query works fine when load is low and does not work on heavy load. I would like to know if three is a way to solve it in my domain code or in eclipselink.

In eclipselink 2.5.2 under heavy load (while running tests) sometimes I'm receiving NullPointerException. I'm not able to reproduce it manually. Application runs on Linux platform with jdk-1.7.0-111_H03-linux_x64.

The stacktrace is:

Caused by: java.lang.NullPointerException
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneNormally(ObjectBuilder.java:904)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:851)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:734)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:688)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:795)
at org.eclipse.persistence.queries.ReadAllQuery.registerResultInUnitOfWork(ReadAllQuery.java:890)
at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:509)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1168)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1127)
at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:403)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1215)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2896)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1804)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1786)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1751)
at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258)
at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:469)

The query is simple select:

SELECT location FROM LocationEntity location " +
        "WHERE  location.locationId IN :locationIds " +
        "AND    :validityDate BETWEEN location.effectiveFrom AND   location.effectiveTo

from dao class annotated with:

@Stateless(name = "LocationDao")
@TransactionAttribute(TransactionAttributeType.SUPPORTS)

The entity is annotated with:

@Entity
@Table(name = "LOCATION")
@Cache(coordinationType = CacheCoordinationType.NONE)
@ReadOnly

It looks like bug in eclipselink. Similar bug is registered under https://bugs.eclipse.org/bugs/show_bug.cgi?id=436871, but stacktrace is different, so in my opinion it is not the same problem.

Community
  • 1
  • 1
  • can you try newer version? – JIV Oct 11 '16 at 08:57
  • Unfortunately not. – Wujek Samo Zło Oct 11 '16 at 09:01
  • The code suggests that the object from the shared cache is being set to null somehow, which is odd since it goes to great lengths to get or create a cache key for it, lock it, then get the object or create a new one. Only after that will the code getting the NPE obtain the object from the cache key and gets this NPE. What JDK and OS versions are you using? Could the instance creation occur in a separate core, such that x!= null but still cause an NPE when x.getClass() is called? – Chris Oct 11 '16 at 19:45
  • Application runs on Linux with jdk-1.7.0-111_H03-linux_x64. It runs on one core so such scenario is not possible. – Wujek Samo Zło Oct 12 '16 at 07:41
  • My suspicion is, that problem is with cacheKey object, which is returned from method buildObject in line 941. I've checked that there WeakCacheKey is used. Is it possible, that before object is returned to `buildWorkingCopyCloneNormally` method it is cleared by garbage collector and because of that `parentCacheKey.getObject()` throws NPE? – Wujek Samo Zło Oct 12 '16 at 07:53

0 Answers0