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.13k stars 572 forks source link

J2CA0081E: Method destroy failed occurs during server shutdown #28350

Closed tkburroughs closed 1 week ago

tkburroughs commented 1 week ago

Describe the bug
The following error intermittently occurs when the server is stopped (or a data source configuration update occurs) while asynchronous tasks are running that access a database:

J2CA0081E: Method destroy failed while trying to execute method destroy on ManagedConnection WSRdbManagedConnectionImpl@ae87e52e from resource No longer available. Caught exception: java.lang.NullPointerException: Cannot invoke "java.sql.Connection.rollback()" because "this.sqlConn" is null     at componenttest.topology.impl.LibertyServer.checkLogsForErrorsAndWarnings(LibertyServer.java:3344)     at componenttest.topology.impl.LibertyServer.stopServer(LibertyServer.java:3170)     at componenttest.topology.impl.LibertyServer.stopServer(LibertyServer.java:3051)     at componenttest.topology.impl.LibertyServer.stopServer(LibertyServer.java:3032)     at componenttest.topology.impl.LibertyServer.stopServer(LibertyServer.java:2941)     at componenttest.topology.impl.LibertyServer.stopServer(LibertyServer.java:2916)     at com.ibm.ws.concurrent.persistent.fat.configupd.db.ExecEnabledDBStoreConfigUpdateTest.afterSuite(ExecEnabledDBStoreConfigUpdateTest.java:69)     at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)     at componenttest.custom.junit.runner.FATRunner$2.evaluate(FATRunner.java:363)     at componenttest.custom.junit.runner.FATRunner.run(FATRunner.java:177)

A serviceability improvement will be made to better handle this scenario and avoid the NullPointerException. A more meaningful message will be logged.

Steps to Reproduce
Submit asynchronous tasks by either creating EJB persistent timers or submitting a task to a PersistentExecutor, then while the timer or task is running, stop the server or modify the database configuration.

Expected behavior
No errors or a clear error indicating the timer or task could not be completed because the server is shutting down.

Diagnostic information:

Additional context
Add any other context about the problem here.