Uploaded image for project: 'JBoss Transaction Manager'
  1. JBoss Transaction Manager
  2. JBTM-3442

@Transactional applied with a CDI InterceptionFactory throws an Exception

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 5.12.0.Final
    • 5.10.5.Final
    • JTA
    • None

      If I try to apply @Transactional on a bean through InterceptionFactory like this:

      interface MyService {
          void doSomething() throws Exception;
      }
      
      @Produces
      @ApplicationScoped
      public MyService myService(InterceptionFactory<MyService> interceptionFactory) {
          interceptionFactory.configure().add(new TransactionalLiteral(Transactional.TxType.REQUIRED));
          return interceptionFactory.createInterceptedInstance(() -> System.out.println(TransactionManager.transactionManager().getStatus()));
      }
      

      and call the MyService.doSomething() method somewhere in my application, I can see 0 being printed (which says that there is an active transaction) but I still get the following exception after invocation:

      java.lang.NullPointerException
      	at com.arjuna.ats.jta.cdi.transactional.TransactionalInterceptorBase.getTransactional(TransactionalInterceptorBase.java:109)
      	at com.arjuna.ats.jta.cdi.transactional.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:188)
      	at com.arjuna.ats.jta.cdi.transactional.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:168)
      	at com.arjuna.ats.jta.cdi.transactional.TransactionalInterceptorRequired.doIntercept(TransactionalInterceptorRequired.java:53)
      	at com.arjuna.ats.jta.cdi.transactional.TransactionalInterceptorBase.intercept(TransactionalInterceptorBase.java:86)
      	at com.arjuna.ats.jta.cdi.transactional.TransactionalInterceptorRequired.intercept(TransactionalInterceptorRequired.java:47)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.jboss.weld.interceptor.reader.SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(SimpleInterceptorInvocation.java:73)
      	at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeAroundInvoke(InterceptorMethodHandler.java:84)
      	at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeInterception(InterceptorMethodHandler.java:72)
      	at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.invoke(InterceptorMethodHandler.java:56)
      	at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:79)
      	at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:68)
      	at org.jboss.weld.bean.proxy.InterceptedProxyMethodHandler.invoke(InterceptedProxyMethodHandler.java:61)
      

      The interceptor is trying to find the @Transactional annotation on the AnnotatedType but fails as it has been added via the InterceptionFactory. I know there is no easy solution as long as CDI-468 is not solved but do you think there is a workaround?

              ochaloup@redhat.com Ondrej Chaloupka (Inactive)
              xavierdury Xavier Dury (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: