Describe the bug
Liberty fails with NullPointerException from internal code when the user specfies an application-defined data source with a java:module name for a Jakarta Persistence persistence unit. If I switch to java:comp it works fine, but fails with java:module,
java.lang.NullPointerException: Cannot invoke "com.ibm.ws.injectionengine.osgi.internal.OSGiInjectionScopeData.processDeferredReferenceData()" because "scopeData" is null
at com.ibm.ws.injectionengine.osgi.internal.naming.DeferredNonCompInjectionJavaColonHelper.getInjectionScopeData(DeferredNonCompInjectionJavaColonHelper.java:39)
at com.ibm.ws.injectionengine.osgi.internal.naming.InjectionJavaColonHelper.getInjectionBinding(InjectionJavaColonHelper.java:135)
at com.ibm.ws.injectionengine.osgi.internal.naming.InjectionJavaColonHelper.getObjectInstance(InjectionJavaColonHelper.java:115)
at com.ibm.ws.jndi.url.contexts.javacolon.internal.JavaURLContext.lookup(JavaURLContext.java:334)
at com.ibm.ws.jndi.url.contexts.javacolon.internal.JavaURLContext.lookup(JavaURLContext.java:372)
at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:149)
at java.naming/javax.naming.InitialContext.lookup(InitialContext.java:409)
at com.ibm.ws.jpa.container.osgi.internal.OSGiJPAPUnitInfo.lookupDataSource(OSGiJPAPUnitInfo.java:319)
at com.ibm.ws.jpa.management.JPAPUnitInfo.getJPADataSource(JPAPUnitInfo.java:343)
at com.ibm.ws.jpa.management.JPAPUnitInfo.getJtaDataSource(JPAPUnitInfo.java:386)
at com.ibm.ws.jpa.management.JPAPUnitInfo.initialize(JPAPUnitInfo.java:756)
at com.ibm.ws.jpa.management.JPAPxmlInfo.extractPersistenceUnits(JPAPxmlInfo.java:184)
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.processWebModulePersistenceXml(JPAComponentImpl.java:597)
at com.ibm.ws.jpa.container.osgi.internal.JPAComponentImpl.applicationStarting(JPAComponentImpl.java:380)
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:549)
at com.ibm.ws.app.manager.module.internal.SimpleDeployedAppInfoBase.installApp(SimpleDeployedAppInfoBase.java:510)
at com.ibm.ws.app.manager.module.internal.DeployedAppInfoBase.deployApp(DeployedAppInfoBase.java:351)
at com.ibm.ws.app.manager.war.internal.WARApplicationHandlerImpl.install(WARApplicationHandlerImpl.java:67)
at com.ibm.ws.app.manager.internal.statemachine.StartAction.execute(StartAction.java:184)
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:247)
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:889)
which shows in messages.log as:
[7/13/23, 10:20:12:005 CDT] 0000004d com.ibm.ws.app.manager.AppMessageHelper E CWWKZ0002E: An exception occurred while starting the application DataValidationTestApp. The exception message was: com.ibm.ws.container.service.state.StateChangeException: java.lang.NullPointerException: Cannot invoke "com.ibm.ws.injectionengine.osgi.internal.OSGiInjectionScopeData.processDeferredReferenceData()" because "scopeData" is null
Steps to Reproduce
In persistence.xml,
<persistence-unit name="MyPersistenceUnit">
<jta-data-source>java:module/jdbc/DerbyDataSource</jta-data-source>
In the application,
@DataSourceDefinition(name = "java:module/jdbc/DerbyDataSource", ...)
...
@PersistenceUnit(unitName = "MyPersistenceUnit")
EntityManagerFactory emf;
**Expected behavior**
Should start up cleanly and supply the EntityManagerFactory to the application.
**Diagnostic information:**
- OpenLiberty Version: latest in development
- Affected feature(s) persistence-3.1
- Java Version:
java.version = 17.0.3
java.runtime = IBM Semeru Runtime Open Edition (17.0.3+7)
os = Mac OS X (13.4; x86_64) (en_US)
- server.xml configuration (WITHOUT sensitive information like passwords)
Refer to the bean validation test for Jakarta Data (which hasn't been delivered yet but probably will be by the time someone works on this)
beanValidation-3.0
componenttest-2.0
data-1.0
jndi-1.0
persistence-3.1
servlet-6.0
```
- If it would be useful, upload the messages.log file found in `$WLP_OUTPUT_DIR/messages.log`
Additional context
Add any other context about the problem here.
Describe the bug
Liberty fails with NullPointerException from internal code when the user specfies an application-defined data source with a
java:modulename for a Jakarta Persistence persistence unit. If I switch tojava:compit works fine, but fails withjava:module,which shows in messages.log as:
Steps to Reproduce
In persistence.xml,
In the application,
@DataSourceDefinition(name = "java:module/jdbc/DerbyDataSource", ...)
...
@PersistenceUnit(unitName = "MyPersistenceUnit")
EntityManagerFactory emf;
java.version = 17.0.3
java.runtime = IBM Semeru Runtime Open Edition (17.0.3+7)
os = Mac OS X (13.4; x86_64) (en_US)
Additional context
Add any other context about the problem here.