Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » NullPointerException on Eclipselink LAZY loading(NullPointerException on Eclipselink LAZY loading)
icon8.gif  NullPointerException on Eclipselink LAZY loading [message #1753405] Mon, 06 February 2017 04:42 Go to next message
anuradha pemmasani is currently offline anuradha pemmasaniFriend
Messages: 5
Registered: February 2017
Junior Member
Eclipselink LAZY loading is throwing the following exception for getter method call, not sure what is the root cause and how to solve this problem.




ABC POJO class

@OneToMany(mappedBy = "owner", fetch = FetchType.LAZY)
private List<EffectiveData> effectiveData;



ABCProcessor.java
List<EffectiveData> enrollmentEffectiveDataList = enrollment.getEffectiveData(); //FIXME issue with LAZY loading.
if (CollectionUtils.isEmpty(enrollmentEffectiveDataList))
{
throw new JobExecutionException("Error .....................");
}

We are getting NullPointerException irrespective of if condition (removed if condition and tested still getting NPE)

What circumstance we will get the NPE for LAZY loading and please suggest ?




[EL Warning]: 2017-02-03 16:59:18.885--UnitOfWork(1000024707)--java.lang.NullPointerException
at org.eclipse.persistence.internal.sessions.AbstractSession.executeDeferredEvents(AbstractSession.java:1454)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2897)
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.indirection.NoIndirectionPolicy.valueFromQuery(NoIndirectionPolicy.java:326)
at org.eclipse.persistence.mappings.ForeignReferenceMapping.valueFromRowInternal(ForeignReferenceMapping.java:2294)
at org.eclipse.persistence.mappings.OneToOneMapping.valueFromRowInternal(OneToOneMapping.java:1860)
at org.eclipse.persistence.mappings.ForeignReferenceMapping.valueFromRow(ForeignReferenceMapping.java:2144)
at org.eclipse.persistence.mappings.ForeignReferenceMapping.buildCloneFromRow(ForeignReferenceMapping.java:336)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildAttributesIntoWorkingCopyClone(ObjectBuilder.java:1996)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneFromRow(ObjectBuilder.java:2249)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:847)
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.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:129)
at org.eclipse.persistence.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:116)
at org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:89)
at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiateImpl(UnitOfWorkValueHolder.java:173)
at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:234)
at org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:89)
at org.eclipse.persistence.indirection.IndirectList.buildDelegate(IndirectList.java:252)
at org.eclipse.persistence.indirection.IndirectList.getDelegate(IndirectList.java:423)
at org.eclipse.persistence.indirection.IndirectList.isEmpty(IndirectList.java:498)
at org.apache.commons.collections.CollectionUtils.isEmpty(CollectionUtils.java:979)
at com.ABCProcessor.process(ABCProcessor.java:60)
at com.ABCProcessor.process(ABCProcessor.java:42)
at sun.reflect.GeneratedMethodAccessor150.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at com.sun.proxy.$Proxy200.process(Unknown Source)
at org.springframework.batch.core.step.item.SimpleChunkProcessor.doProcess(SimpleChunkProcessor.java:126)
at org.springframework.batch.core.step.item.FaultTolerantChunkProcessor$1.doWithRetry(FaultTolerantChunkProcessor.java:225)
at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:263)
at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:193)
at org.springframework.batch.core.step.item.BatchRetryTemplate.execute(BatchRetryTemplate.java:217)
at org.springframework.batch.core.step.item.FaultTolerantChunkProcessor.transform(FaultTolerantChunkProcessor.java:290)
at org.springframework.batch.core.step.item.SimpleChunkProcessor.process(SimpleChunkProcessor.java:192)
at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:75)
at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:406)
at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:330)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:271)
at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:81)
at org.springframework.batch.repeat.support.TaskExecutorRepeatTemplate$ExecutingRunnable.run(TaskExecutorRepeatTemplate.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

[Updated on: Tue, 07 February 2017 20:02]

Report message to a moderator

Re: NullPointerException on Eclipselink LAZY loading [message #1753575 is a reply to message #1753405] Tue, 07 February 2017 19:29 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1275
Registered: July 2009
Senior Member
The stack trace shows it isn't a problem with the mapping, but is occurring when building the referenced entity. The referenced entity has a OneToOneMapping type mapping that is eagerly fetched, and this is causing an issue somehow. Please show the referenced descriptor, and maybe try the latest EclipseLink version if possible
Re: NullPointerException on Eclipselink LAZY loading [message #1753576 is a reply to message #1753575] Tue, 07 February 2017 20:03 Go to previous messageGo to next message
anuradha pemmasani is currently offline anuradha pemmasaniFriend
Messages: 5
Registered: February 2017
Junior Member
I have updated the message, please let me know if it is not providing the complete information.
Re: NullPointerException on Eclipselink LAZY loading [message #1753577 is a reply to message #1753576] Tue, 07 February 2017 20:06 Go to previous messageGo to next message
anuradha pemmasani is currently offline anuradha pemmasaniFriend
Messages: 5
Registered: February 2017
Junior Member
We don't want to use EAGER fetch type, we would like to know how to solve the problem for LAZY loading and the root cause for this NPE.
Re: NullPointerException on Eclipselink LAZY loading [message #1753680 is a reply to message #1753577] Wed, 08 February 2017 18:05 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1275
Registered: July 2009
Senior Member
The point is that you ARE using eager on a relationship. In this case, it seems you have a lazy relationship between Class A and Class B. When this relationship is triggered, an instance of class B is being built - doing so causes relationship to Class C to be fetched as it is an Eager 1:1 type mapping. This class C must have some event processing that is causing or related to the issue you see. Class B seems to be EffectiveData, but without this class, but we need to see it and what ever Class C is to help debug the problem.

I can't help with what is happening without more information. This is also a duplicate of https://www.eclipse.org/forums/index.php/t/1084183/ - I suggest you close one
Previous Topic:Issue with Eclipselink LAZY loading
Next Topic:Eclipselink Performance test failed at 95 percentile
Goto Forum:
  


Current Time: Wed Dec 13 16:58:59 GMT 2017

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

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