NullPointerException in com.sun.jts.CosTransactions.RecoveryManager when restoring EJB timers


we came across this issue with Payara 5.2020.4 and I just wanted to check if my understanding is correct.
One of our instances threw the following exception during startup:

[2021-09-09 06:03:54,145] [INFO ] [] [Thread-21] [#1] ejb.timer_service_started [2021-09-09 06:03:54,145] [INFO ] [] [Thread-21] [#1] ==> Restoring Timers ...
[2021-09-09 06:03:54,280] [INFO ] [org.eclipse.persistence.session./file:/home/xxx/applications/ejb-timer-service-app/WEB-INF/classes/___EJB__Timer__App] [Thread-21] [#1] EclipseLink, version: Eclipse Persistence Services - 2.7.6.payara-p1
[2021-09-09 06:04:01,096] [WARN ] [] [Thread-21] [#1] jts.unexpected_error_in_begin java.lang.NullPointerException at com.sun.jts.CosTransactions.RecoveryManager.waitForResync(
    at com.sun.jts.CosTransactions.TransactionFactoryImpl.localCreate(
    at com.sun.jts.CosTransactions.CurrentImpl.begin(
    at com.sun.jts.jta.TransactionManagerImpl.begin(
    at com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate.beginJTS(
    at com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate.startJTSTx(
    at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.startJTSTx(
    at com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate.enlistLAOResource(
    at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.enlistResource(
    at com.sun.enterprise.resource.rm.SystemResourceManagerImpl.enlistResource(

If I am not mistaken, the underlying source code should be this:

The field which is checked for NULL is static volatile but AFAIK this does not prevent other threads from NULLing the field concurrently after it has been checked, for example here:

Is someone able to confirm this? This issue occurred only once up to now.

Many thanks in advance and best regards,


Yes, you’re right Chris, and congratulations to being that lucky hitting that race condition :slight_smile:

The fix would be to assign resyncInProgress to local variable before checking, as the semaphore would synchronize interleaved post and wait calls properly.

1 Like

Hi Chris,

Can you create a Github issue for this so that we can address this problem in a future version? A PR for this is also appreciated.


1 Like

Thanks for your replies and sorry for not responding earlier. I was expecting to get an email for new posts but somehow I didn’t. (unrelated question: how can I enable mail notifications?)

I will open a github issue and maybe even a PR (as time permits).

Thanks again.

Created Bug Report: NullPointerException in com.sun.jts.CosTransactions.RecoveryManager · Issue #5491 · payara/Payara · GitHub