BTM
  1. BTM
  2. BTM-85

NullPointerException in BitronixTransactionSynchronizationRegistry

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.0.1
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Hi,

      I tried to use TransactionSynchronizationRegistry interface (part of JTA 1.1 spec) but got following exception instead:

      java.lang.NullPointerException
      at bitronix.tm.BitronixTransactionSynchronizationRegistry.getResource(BitronixTransactionSynchronizationRegistry.java:45)
      at (...... - not important)

      I checked the code and it looks like the ThreadLocal value is not properly initialized for new threads.
      Instead of:

      private final static ThreadLocal resourcesTl = new ThreadLocal();

      public BitronixTransactionSynchronizationRegistry()

      { transactionManager = TransactionManagerServices.getTransactionManager(); resourcesTl.set(new HashMap()); }

      the code should read:

      private final static ThreadLocal resourcesTl = new ThreadLocal() {
      protected Object initialValue()

      { return new HashMap(); }

      };

      public BitronixTransactionSynchronizationRegistry()

      { transactionManager = TransactionManagerServices.getTransactionManager(); }

        Activity

        Hide
        Ludovic Orban added a comment -

        Fixed in trunk; new 2.0.1-SNAPSHOT build has been uploaded so you can easily try it out. See http://docs.codehaus.org/display/BTM/Maven2

        Please report back if this new version works for you.

        Show
        Ludovic Orban added a comment - Fixed in trunk; new 2.0.1-SNAPSHOT build has been uploaded so you can easily try it out. See http://docs.codehaus.org/display/BTM/Maven2 Please report back if this new version works for you.
        Hide
        Leszek Kowalski added a comment -

        Thanks for the fast response. New version works OK for me.

        Show
        Leszek Kowalski added a comment - Thanks for the fast response. New version works OK for me.

          People

          • Assignee:
            Ludovic Orban
            Reporter:
            Leszek Kowalski
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: