Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EclipseLink NullPointerException Cannot read field "index" because "key" is null #28078

Open
njr-11 opened this issue Apr 3, 2024 · 7 comments · Fixed by #29200
Open

EclipseLink NullPointerException Cannot read field "index" because "key" is null #28078

njr-11 opened this issue Apr 3, 2024 · 7 comments · Fixed by #29200
Labels
in:JPA release bug This bug is present in a released version of Open Liberty team:Blizzard

Comments

@njr-11
Copy link
Contributor

njr-11 commented Apr 3, 2024

Describe the bug

The JPQL query SELECT o FROM Account o WHERE (o.accountId=?1) fails when supplied with an AccountId that is an embeddable id for the entity.

EclipseLink converts this to SQL: SELECT BALANCE, BANKNAME, CHECKING, OWNER, ACCOUNTNUM, ROUTINGNUM FROM WLPAccount WHERE ((ACCOUNTNUM = ?) AND (ROUTINGNUM = ?))
which looks fine, but it gets an error processing the result: NullPointerException: Cannot read field "index" because "key" is null.

junit.framework.AssertionFailedError: 2024-04-03-11:04:47:525 ERROR: Caught exception attempting to call test method testLiteralDouble on servlet test.jakarta.data.jpa.web.DataJPATestServlet
jakarta.data.exceptions.DataException: jakarta.persistence.PersistenceException: java.lang.NullPointerException: Cannot read field "index" because "key" is null
at io.openliberty.data.internal.persistence.RepositoryImpl.failure(RepositoryImpl.java:607)
at io.openliberty.data.internal.persistence.RepositoryImpl.invoke(RepositoryImpl.java:2859)
at jdk.proxy11/jdk.proxy11.$Proxy100.findByAccountId(Unknown Source)
at test.jakarta.data.jpa.web.DataJPATestServlet.testLiteralDouble(DataJPATestServlet.java:2049)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at componenttest.app.FATServlet.doGet(FATServlet.java:73)
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:527)
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:614)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1260)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:748)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:445)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1361)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1077)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:77)
at com.ibm.ws.webcontainer40.servlet.CacheServletWrapper40.handleRequest(CacheServletWrapper40.java:87)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:969)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:293)
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:1260)
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.wrapHandlerAndExecute(HttpDispatcherLink.java:476)
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:435)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:569)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:503)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:363)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.ready(HttpInboundLink.java:330)
at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:169)
at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:77)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.requestComplete(WorkQueueManager.java:516)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.attemptIO(WorkQueueManager.java:586)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.workerRun(WorkQueueManager.java:970)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:1059)
at com.ibm.ws.threading.internal.ExecutorServiceImpl$RunnableWrapper.run(ExecutorServiceImpl.java:280)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:857)
Caused by: jakarta.persistence.PersistenceException: java.lang.NullPointerException: Cannot read field "index" because "key" is null
at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:494)
at io.openliberty.data.internal.persistence.RepositoryImpl.invoke(RepositoryImpl.java:2570)
Caused by: java.lang.NullPointerException: Cannot read field "index" because "key" is null
at org.eclipse.persistence.internal.sessions.ArrayRecord.get(ArrayRecord.java:139)
at org.eclipse.persistence.descriptors.InheritancePolicy.classFromRow(InheritancePolicy.java:365)
at org.eclipse.persistence.mappings.AggregateObjectMapping.buildAggregateFromRow(AggregateObjectMapping.java:440)
at org.eclipse.persistence.mappings.AggregateObjectMapping.buildCloneFromRow(AggregateObjectMapping.java:786)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildAttributesIntoWorkingCopyClone(ObjectBuilder.java:2111)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneFromRow(ObjectBuilder.java:2364)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:958)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInternal(ObjectBuilder.java:844)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:799)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:777)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:863)
at org.eclipse.persistence.queries.ReadObjectQuery.registerResultInUnitOfWork(ReadObjectQuery.java:896)
at org.eclipse.persistence.queries.ReadObjectQuery.executeObjectLevelReadQuery(ReadObjectQuery.java:570)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1236)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:913)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1195)
at org.eclipse.persistence.queries.ReadObjectQuery.execute(ReadObjectQuery.java:448)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1283)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:3025)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1841)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1823)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1788)
at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:263)
at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:475) 

Steps to Reproduce
Uncomment these lines of code and run the test:

// TODO Enable the following once fixed,
//Account account = accounts.findByAccountId(id);
//assertEquals(331.16, account.balance, 0.001);
// Failure is:
// Caused by: java.lang.NullPointerException: Cannot read field "index" because "key" is null
// at org.eclipse.persistence.internal.sessions.ArrayRecord.get(ArrayRecord.java:139) ...

Expected behavior
JPQL query should succeed and return the data.

Diagnostic information:

  • OpenLiberty Version: latest from integration. Not in a beta release yet.
  • Affected feature(s) data-1.0, persistence-3.1
  • Java Version: IBM Semeru Runtime Open Edition (17.0.8+7)
  • server.xml configuration - see test bucket

Additional context
Add any other context about the problem here.

@njr-11 njr-11 added in:JPA team:Blizzard release bug This bug is present in a released version of Open Liberty labels Apr 3, 2024
@Riva-Tholoor-Philip
Copy link
Contributor

See EclipseLink Issue : 2195

KyleAure added a commit to KyleAure/open-liberty that referenced this issue Jul 25, 2024
@KyleAure
Copy link
Member

FYI @njr-11 @Riva-Tholoor-Philip

I was unable to recreate. I also un-commented and ran the original test and it works from Jakarta Data as well.
Perhaps this bug was fixed in one of the beta versions of EclipseLink we have upgraded too?

My recreation attempt: KyleAure@1483d53

@njr-11
Copy link
Contributor Author

njr-11 commented Jul 25, 2024

I was unable to recreate. I also un-commented and ran the original test and it works from Jakarta Data as well.
Perhaps this bug was fixed in one of the beta versions of EclipseLink we have upgraded too?

Oh, I didn't realize it worked via Jakarta Data now, too. Then yes, EclipseLink must have fixed it already. I just tried it locally as well and given that worked, and I requested a build to confirm that its working there as well. I set up the PR to automatically close this issue.

njr-11 added a commit to njr-11/open-liberty that referenced this issue Jul 26, 2024
@njr-11
Copy link
Contributor Author

njr-11 commented Jul 26, 2024

When I attempted to re-enable this under #29200 I discovered that it's an intermittent issue that appears to happen when the test testEmbeddedId, which uses the same entity, runs first.

@Riva-Tholoor-Philip
Copy link
Contributor

Thanks @njr-11

@KyleAure
Copy link
Member

Reopening issue. The PR accidentally automatically closed this, it is still an issue that needs to be resolved.

@covener
Copy link
Member

covener commented Sep 10, 2024

remove release:24.0.0.9 label (this OLGH is incorrectly in the fix pack metadata)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in:JPA release bug This bug is present in a released version of Open Liberty team:Blizzard
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants