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

DateTimeParseException reading Instant column with Persistence 3.2 #28813

Open
njr-11 opened this issue Jun 19, 2024 · 7 comments
Open

DateTimeParseException reading Instant column with Persistence 3.2 #28813

njr-11 opened this issue Jun 19, 2024 · 7 comments
Assignees
Labels
bug This bug is not present in a released version of Open Liberty in:JPA

Comments

@njr-11
Copy link
Contributor

njr-11 commented Jun 19, 2024

Describe the bug
When Persistence 3.2 is used to query for an entity that has an attribute of type Instant, it gets a DateTimeParseException.

See test.jakarta.data.jpa.web.DemographicInfo, which has this attribute:

    @Column
    public Instant collectedOn;

and the following JPQL which read entities of that type:

SELECT o FROM DemographicInfo o WHERE (o.publicDebt BETWEEN ?1 AND ?2) ORDER BY o.publicDebt

The following exception is raised:

[6/19/24, 11:38:25:713 CDT] 00000051 id=00000000 eclipselink.ps                                               3 CWWKD0291W: Exception [EclipseLink-3002] (Eclipse Persistence Services - 5.0.0-B02.v202404111748): org.eclipse.persistence.exceptions.ConversionException
Exception Description: The object [2007-04-30 11:00:00.0], of class [class java.lang.String], from mapping [org.eclipse.persistence.mappings.DirectToFieldMapping[collectedOn-->WLPDemographicInfo.COLLECTEDON]] with descriptor [RelationalDescriptor(test.jakarta.data.jpa.web.DemographicInfo --> [DatabaseTable(WLPDemographicInfo)])], could not be converted to [class java.time.Instant].
Internal Exception: java.time.format.DateTimeParseException: Text '2007-04-30 11:00:00.0' could not be parsed at index 10
[6/19/24, 11:38:25:713 CDT] 00000051 id=00000000 eclipselink.ps                                               3 throwable 
                                                                                                               Local Exception Stack: 
Exception [EclipseLink-3002] (Eclipse Persistence Services - 5.0.0-B02.v202404111748): org.eclipse.persistence.exceptions.ConversionException
Exception Description: The object [2007-04-30 11:00:00.0], of class [class java.lang.String], from mapping [org.eclipse.persistence.mappings.DirectToFieldMapping[collectedOn-->WLPDemographicInfo.COLLECTEDON]] with descriptor [RelationalDescriptor(test.jakarta.data.jpa.web.DemographicInfo --> [DatabaseTable(WLPDemographicInfo)])], could not be converted to [class java.time.Instant].
Internal Exception: java.time.format.DateTimeParseException: Text '2007-04-30 11:00:00.0' could not be parsed at index 10
	at org.eclipse.persistence.exceptions.ConversionException.couldNotBeConverted(ConversionException.java:95)
	at org.eclipse.persistence.internal.helper.ConversionManager.convertObject(ConversionManager.java:251)
	at org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform.convertObject(DatasourcePlatform.java:252)
	at org.eclipse.persistence.mappings.foundation.AbstractDirectMapping.getObjectValue(AbstractDirectMapping.java:659)
	at org.eclipse.persistence.mappings.foundation.AbstractDirectMapping.valueFromRow(AbstractDirectMapping.java:1271)
	at org.eclipse.persistence.mappings.foundation.AbstractDirectMapping.buildCloneFromRow(AbstractDirectMapping.java:238)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildAttributesIntoWorkingCopyClone(ObjectBuilder.java:2109)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneFromRow(ObjectBuilder.java:2362)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:956)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInternal(ObjectBuilder.java:842)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:797)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:775)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:924)
	at org.eclipse.persistence.queries.ReadAllQuery.registerResultInUnitOfWork(ReadAllQuery.java:987)
	at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:598)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1297)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:934)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1256)
	at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:485)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1344)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:3015)
	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:480)
	at io.openliberty.data.internal.persistence.RepositoryImpl.invoke(RepositoryImpl.java:909)
	at jdk.proxy11/jdk.proxy11.$Proxy77.findByPublicDebtBetween(Unknown Source)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:38)
	at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:109)
	at test.jakarta.data.jpa.web.Demographics$210985159$Proxy$_$$_WeldClientProxy.findByPublicDebtBetween(Unknown Source)
	at test.jakarta.data.jpa.web.DataJPATestServlet.testBigDecimal(DataJPATestServlet.java:286)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at componenttest.app.FATServlet.doGet(FATServlet.java:74)
	at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:633)
	at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:723)
	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1266)
	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:754)
	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:451)
	at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1362)
	at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1078)
	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:978)
	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:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.time.format.DateTimeParseException: Text '2007-04-30 11:00:00.0' could not be parsed at index 10
	at java.base/java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:2108)
	at java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:2010)
	at java.base/java.time.Instant.parse(Instant.java:398)
	at org.eclipse.persistence.internal.helper.ConversionManager.convertObjectToInstant(ConversionManager.java:863)
	at org.eclipse.persistence.internal.helper.ConversionManager.convertObject(ConversionManager.java:196)
	... 63 more

Steps to Reproduce
Re-enable test.jakarta.data.jpa.web.DataJPATestServlet.testBigDecimal() and test.jakarta.data.jpa.web.DataJPATestServlet.testBigInteger(), which, despite their names, are also testing Instant. These had to be disabled when switching the server.xml from persistence-3.1 to persistence-3.2.

Expected behavior
Successful retrieval of the entity, as happens with Persistence 3.1.

Diagnostic information:

  • OpenLiberty Version: latest in development
  • Affected feature(s) persistence-3.2, which breaks data-1.0
  • Java Version:
java.home = /Users/njr/drivers/jdk-21.jdk/Contents/Home
java.version = 21
java.runtime = OpenJDK Runtime Environment (21+35-2513)
os = Mac OS X (14.5; aarch64) (en_US)
  • server.xml configuration - refer to test case
@njr-11 njr-11 added bug This bug is not present in a released version of Open Liberty in:JPA labels Jun 19, 2024
@Riva-Tholoor-Philip
Copy link
Contributor

See EclipseLink Issue : 2191

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

KyleAure commented Jul 24, 2024

@Riva-Tholoor-Philip @njr-11

I wasn't able to replicate this behavior using only JPA.

io.openliberty.data.internal_fat_jpa (failure)

Output

[7/24/24, 10:54:18:056 CDT] 0000004f id=00000000 eclipselink.ps.sql                                           3 INSERT INTO WLPDemographicInfo (ID, COLLECTEDON, INTRAGOVERNMENTALDEBT, NUMFULLTIMEWORKERS, PUBLICDEBT) VALUES (?, ?, ?, ?, ?)
  bind => [33, 2007-04-30T16:00:00Z, 3833110332444.19, 121090000, 5007058051986.64]

[7/24/24, 10:54:18:125 CDT] 0000004f id=00000000 eclipselink.ps.sql                                           3 SELECT ID, COLLECTEDON, INTRAGOVERNMENTALDEBT, NUMFULLTIMEWORKERS, PUBLICDEBT FROM WLPDemographicInfo WHERE (PUBLICDEBT BETWEEN ? AND ?) ORDER BY PUBLICDEBT
  bind => [5.0E+12, 1.0E+13]

[7/24/24, 10:54:18:134 CDT] 0000004f id=00000000 eclipselink.ps                                               3 CWWKD0291W: Exception [EclipseLink-3002] (Eclipse Persistence Services - 5.0.0-B02.v202404111748): org.eclipse.persistence.exceptions.ConversionException
Exception Description: The object [2007-04-30 11:00:00.0], of class [class java.lang.String], from mapping [org.eclipse.persistence.mappings.DirectToFieldMapping[collectedOn-->WLPDemographicInfo.COLLECTEDON]] with descriptor [RelationalDescriptor(test.jakarta.data.jpa.web.DemographicInfo --> [DatabaseTable(WLPDemographicInfo)])], could not be converted to [class java.time.Instant].
Internal Exception: java.time.format.DateTimeParseException: Text '2007-04-30 11:00:00.0' could not be parsed at index 10

Notes

Looks like something got corrupted. Eclipse link shows putting in the correct date/time 2007-04-30T16:00:00Z but when attempting to parse the date/time we see 2007-04-30 11:00:00.0 in the error.

com.ibm.ws.jpa.tests.jpa_32_fat (success)

Output

[7/24/24, 11:03:47:287 CDT] 00000048 eclipselink                                                              I CWWJP9990I: [eclipselink] EclipseLink, version: Eclipse Persistence Services - 5.0.0-B02.v202404111748
[7/24/24, 11:03:56:636 CDT] 00000048 id=00000000 eclipselink.sql                                              3 [eclipselink.sql] INSERT INTO DEMOGRAPHICINFO (ID, COLLECTEDON, INTRAGOVERNMENTALDEBT, NUMFULLTIMEWORKERS, PUBLICDEBT) VALUES (?, ?, ?, ?, ?)
  bind => [4, 2007-04-30T16:00:00Z, 3833110332444.19, 121090000, 5007058051986.64]

[7/24/24, 11:03:56:704 CDT] 00000048 id=00000000 eclipselink.sql                                              3 [eclipselink.sql] SELECT ID, COLLECTEDON, INTRAGOVERNMENTALDEBT, NUMFULLTIMEWORKERS, PUBLICDEBT FROM DEMOGRAPHICINFO WHERE (PUBLICDEBT BETWEEN ? AND ?) ORDER BY PUBLICDEBT
  bind => [5.0E+12, 1.0E+13]

[7/24/24, 11:03:56:710 CDT] 00000048 SystemOut                                                                O DemographicInfo from 2007-04-30T16:00:00Z

Notes

Same version of eclipselink, same JVM.

Commit

Here is the commit where I attempted to recreate this issue.

KyleAure@c272791

@KyleAure KyleAure reopened this Jul 24, 2024
@Riva-Tholoor-Philip
Copy link
Contributor

@KyleAure Noted

@njr-11
Copy link
Contributor Author

njr-11 commented Jul 25, 2024

Looks like something got corrupted. Eclipse link shows putting in the correct date/time 2007-04-30T16:00:00Z but when attempting to parse the date/time we see 2007-04-30 11:00:00.0 in the error.

If something is being corrupted on the Jakarta Data path that is not obvious when trying to reproduce, can EclipseLink logging/trace be enabled while reproducing in Jakarta Data such that the same sequence of JPA operations leading up to the error can be used to reproduce in pure JPA?

@ajaypaul-ibm
Copy link
Contributor

@njr-11 and @KyleAure, I wanted to check if there’s been any progress on this. Were you able to enable the trace and attempt to recreate the issue?

@njr-11
Copy link
Contributor Author

njr-11 commented Nov 15, 2024

@njr-11 and @KyleAure, I wanted to check if there’s been any progress on this. Were you able to enable the trace and attempt to recreate the issue?

I can tell you that the tests are still failing if I try to enable them:

java.time.format.DateTimeParseException: Text '2008-04-30 11:00:00.0' could not be parsed at index 10

Otherwise, my prior comment suggested that you enable EclipseLink logging while reproducing it via the Jakarta Data test to help figure out the exact code path that you need on the JPA/EclipseLink side for reproducing the error. That was just an idea - you are welcome to try other approaches for debugging instead or in addition to that. I don't know of anything that you should be waiting on Kyle or I for.

@KyleAure
Copy link
Member

I haven't done any additional investigation into this issue after the initial attempt to re-create the issue.

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

No branches or pull requests

5 participants