OpenLiberty / open-liberty

Open Liberty is a highly composable, fast to start, dynamic application server runtime environment
https://openliberty.io
Eclipse Public License 2.0
1.16k stars 599 forks source link

Test Failure: testDataSourceDefinitionInEJBModule NameNotFoundException: java:global/jdbc/DataSourceDef #28845

Closed njr-11 closed 4 months ago

njr-11 commented 5 months ago

Test Failure: test.jakarta.data.datastore.DataStoreTest.DataStoreTestServlet.testDataSourceDefinitionInEJBModule

DataStoreTestServlet.testDataSourceDefinitionInEJBModule:junit.framework.AssertionFailedError: 2024-06-18-23:05:09:484 ERROR: Caught exception attempting to call test method testDataSourceDefinitionInEJBModule on servlet test.jakarta.data.datastore.web.DataStoreTestServlet
jakarta.ejb.EJBException: See nested exception; nested exception is: java.util.concurrent.CompletionException: javax.naming.NameNotFoundException: javax.naming.NameNotFoundException: java:global/jdbc/DataSourceDef
    at com.ibm.ejs.container.util.ExceptionUtil.EJBException(ExceptionUtil.java:401)
    at com.ibm.ejs.container.util.ExceptionUtil.EJBException(ExceptionUtil.java:287)
    at com.ibm.ejs.container.BusinessExceptionMappingStrategy.mapException(BusinessExceptionMappingStrategy.java:349)
    at com.ibm.ejs.container.BusinessExceptionMappingStrategy.setUncheckedException(BusinessExceptionMappingStrategy.java:521)
    at com.ibm.ejs.container.EJSDeployedSupport.setUncheckedLocalException(EJSDeployedSupport.java:451)
    at test.jakarta.data.datastore.ejb.EJSLocalNSLDataStoreTestEJB_bf8cdd0d.testDataSourceDefinitionInEJBModule(EJSLocalNSLDataStoreTestEJB_bf8cdd0d.java)
    at test.jakarta.data.datastore.web.DataStoreTestServlet.testDataSourceDefinitionInEJBModule(DataStoreTestServlet.java:350)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at componenttest.app.FATServlet.doGet(FATServlet.java:74)
    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: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:1595)
Caused by: java.util.concurrent.CompletionException: javax.naming.NameNotFoundException: javax.naming.NameNotFoundException: java:global/jdbc/DataSourceDef
    at io.openliberty.data.internal.persistence.service.DBStoreEMBuilder.<init>(DBStoreEMBuilder.java:433)
    at io.openliberty.data.internal.persistence.cdi.FutureEMBuilder.createEMBuilder(FutureEMBuilder.java:185)
    at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
Caused by: javax.naming.NameNotFoundException: javax.naming.NameNotFoundException: java:global/jdbc/DataSourceDef
    at com.ibm.ws.jndi.url.contexts.javacolon.internal.JavaURLContext.lookup(JavaURLContext.java:357)
    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 java.naming/javax.naming.InitialContext.doLookup(InitialContext.java:282)
    at io.openliberty.data.internal.persistence.service.DelegatingResourceFactory.createResource(DelegatingResourceFactory.java:59)
    at com.ibm.wsspi.persistence.internal.DatabaseStoreImpl.createPersistenceServiceUnit(DatabaseStoreImpl.java:286)
    at io.openliberty.data.internal.persistence.service.DBStoreEMBuilder.<init>(DBStoreEMBuilder.java:420)

    at componenttest.topology.utils.FATServletClient.assertTestResponse(FATServletClient.java:106)
    at componenttest.topology.utils.FATServletClient.runTest(FATServletClient.java:91)
    at componenttest.custom.junit.runner.SyntheticServletTest.invokeExplosively(SyntheticServletTest.java:44)
    at componenttest.custom.junit.runner.FATRunner$1.evaluate(FATRunner.java:203)
    at componenttest.custom.junit.runner.FATRunner$2.evaluate(FATRunner.java:363)
    at componenttest.custom.junit.runner.FATRunner.run(FATRunner.java:177)

The code has a mechanism in place to wait until we get the signal that the application is started before attempting to perform lookups of application-defined resources. However, it appears that intermittently the java:global/jdbc/DataSourceDef data source defined by the application is still not available yet, resulting in the error.

[6/18/24, 23:04:37:858 PDT] 0000002b com.ibm.ws.app.manager.AppMessageHelper                      A CWWKZ0001I: Application DataStoreTestApp started in 34.043 seconds.

[6/18/24, 23:04:40:159 PDT] 00000052 com.ibm.ws.logging.internal.impl.IncidentImpl                I FFDC1015I: An FFDC Incident has been created: "javax.naming.NameNotFoundException: javax.naming.NameNotFoundException: java:global/jdbc/DataSourceDef io.openliberty.data.internal.persistence.service.DBStoreEMBuilder 430" at ffdc_24.06.18_23.04.38.0.log

[6/18/24, 23:05:08:973 PDT] 0000002b com.ibm.ejs.container.BusinessExceptionMappingStrategy       E CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "testDataSourceDefinitionInEJBModule" on bean "BeanId(DataStoreTestApp#DataStoreTestEJB.jar#DataStoreTestEJB, null)". Exception data: java.util.concurrent.CompletionException: javax.naming.NameNotFoundException: javax.naming.NameNotFoundException: java:global/jdbc/DataSourceDef
    at io.openliberty.data.internal.persistence.service.DBStoreEMBuilder.<init>(DBStoreEMBuilder.java:433)
    at io.openliberty.data.internal.persistence.cdi.FutureEMBuilder.createEMBuilder(FutureEMBuilder.java:185)
    at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
    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:1595)
Caused by: javax.naming.NameNotFoundException: javax.naming.NameNotFoundException: java:global/jdbc/DataSourceDef
    at com.ibm.ws.jndi.url.contexts.javacolon.internal.JavaURLContext.lookup(JavaURLContext.java:357)
    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 java.naming/javax.naming.InitialContext.doLookup(InitialContext.java:282)
    at io.openliberty.data.internal.persistence.service.DelegatingResourceFactory.createResource(DelegatingResourceFactory.java:59)
    at com.ibm.wsspi.persistence.internal.DatabaseStoreImpl.createPersistenceServiceUnit(DatabaseStoreImpl.java:286)
    at io.openliberty.data.internal.persistence.service.DBStoreEMBuilder.<init>(DBStoreEMBuilder.java:420)
    ... 6 more

I could probably put a workaround into our Jakarta Data provider to retry the lookup until successful before invoking into the Persistence Service which will need the data source, getting around this intermittent failure. However, I expect a similar situation could happen with general usage, so if this works, it should be looked into whether something ought to be done more generally.

tkburroughs commented 5 months ago

This issue will be resolved by the following: