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

Not providing Entity in JPQL causes java.lang.ClassCastException #2253

Open
ajaypaul-ibm opened this issue Sep 4, 2024 · 0 comments
Open

Comments

@ajaypaul-ibm
Copy link
Contributor

Getting issue when using named query in JPQL
Please refer logs :

[INFO] [ERROR   ] CWWJP0015E: An error occurred in the org.eclipse.persistence.jpa.PersistenceProvider persistence provider when it attempted to create the container entity manager factory for the AnnuityDSJPAOnly persistence unit. The following error occurred: Exception [EclipseLink-28018] (Eclipse Persistence Services - 5.0.0-B02.v202404111748): org.eclipse.persistence.exceptions.EntityManagerSetupException
[INFO] Exception Description: Predeployment of PersistenceUnit [AnnuityDSJPAOnly] failed.
[INFO] Internal Exception: Exception [EclipseLink-7158] (Eclipse Persistence Services - 5.0.0-B02.v202404111748): org.eclipse.persistence.exceptions.ValidationException
[INFO] Exception Description: Error encountered when building the @NamedQuery [GetHolderAnnuities] from entity class [class org.eclipse.persistence.internal.jpa.metadata.queries.NamedQueryMetadata].
[INFO] Internal Exception: java.lang.ClassCastException: org.eclipse.persistence.jpa.jpql.parser.NullExpression incompatible with org.eclipse.persistence.jpa.jpql.parser.IdentificationVariable

Steps to Reproduce
For a named query, use the new way of defining JPQL For e.g.
FROM Annuity WHERE annuityHolderId = :holderId
instead of SELECT a FROM Annuity AS a WHERE a.annuityHolderId = :holderId
Expected behavior
This new way of using JPQL should work without any issues.

Diagnostic information:

OpenLiberty Version: [Open Liberty 24.0.0.9-beta (wlp-1.0.92.cl240820240729-1903)]
Affected feature(s) [persistence-3.2]
Java Version: [java.version = 20.0.2
java.runtime = IBM Semeru Runtime Open Edition (20.0.2+9)]
server.xml configuration (WITHOUT sensitive information like passwords)
If it would be useful, upload the messages.log file found in $WLP_OUTPUT_DIR/messages.log
Additional context
Here is the ffdc for the error:

------Start of DE processing------ = [8/7/24, 11:29:05:593 CDT ]
Exception = jakarta.persistence.PersistenceException
Source = com.ibm.ws.jpa.management.JPAPUnitInfo.createEMFactory
probeid = 759
Stack Dump = jakarta.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 5.0.0-B02.v202404111748): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [AnnuityDSJPAOnly] failed.
Internal Exception: Exception [EclipseLink-7158] (Eclipse Persistence Services - 5.0.0-B02.v202404111748): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Error encountered when building the @NamedQuery [GetHolderAnnuities] from entity class [class org.eclipse.persistence.internal.jpa.metadata.queries.NamedQueryMetadata].
Internal Exception: java.lang.ClassCastException: org.eclipse.persistence.jpa.jpql.parser.NullExpression incompatible with org.eclipse.persistence.jpa.jpql.parser.IdentificationVariable
        at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:2157)
        at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:2133)
        at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactoryImpl(PersistenceProvider.java:390)
        at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:354)
        at com.ibm.ws.jpa.management.JPAPUnitInfo.createEMFactory(JPAPUnitInfo.java:984)
        at com.ibm.ws.jpa.management.JPAPUnitInfo.initialize(JPAPUnitInfo.java:819)
        at com.ibm.ws.jpa.management.JPAPxmlInfo.extractPersistenceUnits(JPAPxmlInfo.java:190)
        at com.ibm.ws.jpa.management.JPAScopeInfo.processPersistenceUnit(JPAScopeInfo.java:90)
        at com.ibm.ws.jpa.management.JPAApplInfo.addPersistenceUnits(JPAApplInfo.java:121)
        at com.ibm.ws.jpa.container.osgi.internal.JPAComponentImpl.processEJBModulePersistenceXml(JPAComponentImpl.java:651)
        at com.ibm.ws.jpa.container.osgi.internal.JPAComponentImpl.applicationStarting(JPAComponentImpl.java:377)
        at com.ibm.ws.container.service.state.internal.ApplicationStateManager.fireStarting(ApplicationStateManager.java:53)
        at com.ibm.ws.container.service.state.internal.StateChangeServiceImpl.fireApplicationStarting(StateChangeServiceImpl.java:52)
        at com.ibm.ws.app.manager.module.internal.SimpleDeployedAppInfoBase.preDeployApp(SimpleDeployedAppInfoBase.java:550)
        at com.ibm.ws.app.manager.module.internal.SimpleDeployedAppInfoBase.installApp(SimpleDeployedAppInfoBase.java:511)
        at com.ibm.ws.app.manager.module.internal.DeployedAppInfoBase.deployApp(DeployedAppInfoBase.java:625)
        at com.ibm.ws.app.manager.ear.internal.EARApplicationHandlerImpl.install(EARApplicationHandlerImpl.java:79)
        at com.ibm.ws.app.manager.internal.statemachine.StartAction.execute(StartAction.java:199)
        at com.ibm.ws.app.manager.internal.statemachine.ApplicationStateMachineImpl.enterState(ApplicationStateMachineImpl.java:1369)
        at com.ibm.ws.app.manager.internal.statemachine.ApplicationStateMachineImpl.run(ApplicationStateMachineImpl.java:912)
        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:1639)
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 5.0.0-B02.v202404111748): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [AnnuityDSJPAOnly] failed.

**Please note :**The createQuery version of OpenLiberty/open-liberty#29319 was resolved, but not the createNamedQuery version of the same query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant