Uploaded image for project: 'TomEE'
  1. TomEE
  2. TOMEE-2851

sometimes getting null when injecting TransactionSynchronizationRegistry / Injection data not found in JNDI context

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 8.0.1
    • Fix Version/s: None
    • Component/s: TomEE Core Server
    • Labels:
      None
    • Environment:
      linux, java11

      Description

      Hello,

      we're injecting TransactionSynchronizationRegistry in some error handling path in our application:

      @Resource
      private TransactionSynchronizationRegistry transactionSynchronizationRegistry;

      What we do is that we store some meta-data which is valid for the SQL transaction scope in that registry, so that if there is an error down the line, we can tie the error to this meta-data. And this works fine but after days of running a production workload, we get errors because this injection fails.

      We get this error concurrently on multiple threads:

      17-Jun-2020 10:54:53.809 WARNING [managed-thread-18] org.apache.openejb.cdi.CdiResourceInjectionService.fillInjectionProperties Injection data not found in JNDI context: jndiName='comp/env/com.littransit.rabbitmq.RabbitChangesPublisher/transactionSynchronizationRegistry', target=com.littransit.rabbitmq.RabbitChangesPublisher/transactionSynchronizationRegistry17-Jun-2020 10:54:53.810 WARNING [managed-thread-8] org.apache.openejb.cdi.CdiResourceInjectionService.fillInjectionProperties Injection data not found in JNDI context: jndiName='comp/env/com.littransit.rabbitmq.RabbitChangesPublisher/transactionSynchronizationRegistry', target=com.littransit.rabbitmq.RabbitChangesPublisher/transactionSynchronizationRegistry
      17-Jun-2020 10:54:53.810 WARNING [managed-thread-16] org.apache.openejb.cdi.CdiResourceInjectionService.fillInjectionProperties Injection data not found in JNDI context: jndiName='comp/env/com.littransit.rabbitmq.RabbitChangesPublisher/transactionSynchronizationRegistry', target=com.littransit.rabbitmq.RabbitChangesPublisher/transactionSynchronizationRegistry
      17-Jun-2020 10:54:53.809 WARNING [managed-thread-7] org.apache.openejb.cdi.CdiResourceInjectionService.fillInjectionProperties Injection data not found in JNDI context: jndiName='comp/env/com.littransit.rabbitmq.RabbitChangesPublisher/transactionSynchronizationRegistry', target=com.littransit.rabbitmq.RabbitChangesPublisher/transactionSynchronizationRegistry
      17-Jun-2020 10:54:53.811 WARNING [managed-thread-16] org.apache.openejb.cdi.CdiResourceInjectionService.fillInjectionProperties Injection data not found in JNDI context: jndiName='comp/env/com.littransit.rabbitmq.RabbitChangesPublisher/transactionSynchronizationRegistry', target=com.littransit.rabbitmq.RabbitChangesPublisher/transactionSynchronizationRegistry
      17-Jun-2020 10:54:53.812 INFO [managed-thread-16] com.littransit.rabbitmq.RabbitChangesPublisher.handleEventInternal em: org.apache.openejb.persistence.JtaEntityManager@619cca3f - managed-thread-16
      17-Jun-2020 10:54:53.812 WARNING [managed-thread-10] org.apache.openejb.cdi.CdiResourceInjectionService.fillInjectionProperties Injection data not found in JNDI context: jndiName='comp/env/com.littransit.rabbitmq.RabbitChangesPublisher/transactionSynchronizationRegistry', target=com.littransit.rabbitmq.RabbitChangesPublisher/transactionSynchronizationRegistry
      17-Jun-2020 10:54:53.812 WARNING [managed-thread-18] org.apache.openejb.cdi.CdiResourceInjectionService.fillInjectionProperties Injection data not found in JNDI context: jndiName='comp/env/com.littransit.rabbitmq.RabbitChangesPublisher/transactionSynchronizationRegistry', target=com.littransit.rabbitmq.RabbitChangesPublisher/transactionSynchronizationRegistry

      And very shortly afterwards:

      17-Jun-2020 10:54:53.814 SEVERE [managed-thread-16] com.littransit.rabbitmq.RabbitChangesPublisher.handleEventInternal Failed publishing rabbit message
      java.lang.NullPointerException
      at com.littransit.rabbitmq.RabbitChangesPublisher.writeRabbitOutboxAccountItem(RabbitChangesPublisher.java:50)

      And this is a NPE reading the transactionSynchronizationRegistry injected field.

      Shortly afterwards we see this issue again in other managed threads:

      17-Jun-2020 10:54:53.836 WARNING [managed-thread-12] org.apache.openejb.cdi.CdiResourceInjectionService.fillInjectionProperties Injection data not found in JNDI context: jndiName='comp/env/com.littransit.rabbitmq.RabbitChangesPublisher/transactionSynchronizationRegistry', target=com.littransit.rabbitmq.RabbitChangesPublisher/transactionSynchronizationRegistry
      17-Jun-2020 10:54:53.843 WARNING [managed-thread-12] org.apache.openejb.cdi.CdiResourceInjectionService.fillInjectionProperties Injection data not found in JNDI context: jndiName='comp/env/com.littransit.rabbitmq.RabbitChangesPublisher/transactionSynchronizationRegistry', target=com.littransit.rabbitmq.RabbitChangesPublisher/transactionSynchronizationRegistry
      17-Jun-2020 10:54:53.844 WARNING [managed-thread-19] org.apache.openejb.cdi.CdiResourceInjectionService.fillInjectionProperties Injection data not found in JNDI context: jndiName='comp/env/com.littransit.rabbitmq.RabbitChangesPublisher/transactionSynchronizationRegistry', target=com.littransit.rabbitmq.RabbitChangesPublisher/transactionSynchronizationRegistry

      This is happening in managed threads that we instanciated with:

      @Resource
      private ManagedThreadFactory factory;

      Then factory.newThread(...).

      We do not understand how come @Resource TransactionSynchronizationRegistry works, until it doesn't. We are using TOMEE 8.0.1 on java11. It seems to us like a bug, that the injection suddenly stops working.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              emmanueltouzery Emmanuel Touzery
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: