Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-9035

TransactionAttribute annotation is inherited from interface which not according to the spec

XMLWordPrintable

    • Hide

      Simple Bean implementation

      @Stateless
      public class AnnotatedTxBean implements AnnotatedTx {
      private static final Logger log = Logger.getLogger(AnnotatedTxBean.class);
      @Resource
      SessionContext context;

      @TransactionAttribute(TransactionAttributeType.REQUIRED) // this is also the default
      public void checkRollbackForDefaultRequired()

      { log.info("Now checking rollback"); log.info("RollbackOnly is '" + context.getRollbackOnly() + "'"); }

      }

      Interface:
      public interface AnnotatedTx {
      @TransactionAttribute(TransactionAttributeType.NEVER)
      void checkRollbackForDefaultRequired();
      }

      The invocation will fail with:
      WFLYEJB0034: EJB Invocation failed on component AnnotatedTxBean for method public abstract void org.jboss.wfink.ejb31.timer.AnnotatedTx.checkRollbackForDefaultRequired(): javax.ejb.EJBException: WFLYEJB0063: Transaction present on server in Never call (EJB3 13.6.2.6)

      and work if the annotation on interface level is removed

      Show
      Simple Bean implementation @Stateless public class AnnotatedTxBean implements AnnotatedTx { private static final Logger log = Logger.getLogger(AnnotatedTxBean.class); @Resource SessionContext context; @TransactionAttribute(TransactionAttributeType.REQUIRED) // this is also the default public void checkRollbackForDefaultRequired() { log.info("Now checking rollback"); log.info("RollbackOnly is '" + context.getRollbackOnly() + "'"); } } Interface: public interface AnnotatedTx { @TransactionAttribute(TransactionAttributeType.NEVER) void checkRollbackForDefaultRequired(); } The invocation will fail with: WFLYEJB0034: EJB Invocation failed on component AnnotatedTxBean for method public abstract void org.jboss.wfink.ejb31.timer.AnnotatedTx.checkRollbackForDefaultRequired(): javax.ejb.EJBException: WFLYEJB0063: Transaction present on server in Never call (EJB3 13.6.2.6) and work if the annotation on interface level is removed
    • Hide

      Remove any annotation on Business Interface level.

      Show
      Remove any annotation on Business Interface level.

      The annotation @TransactionAttribute is inherited from the business interface which is not according to the EJB specification.
      Any annotation on the bean's implemenation class or deployment descriptor is overridden if the Interface is annotated with @TransactionAttribute

      The EJB 3.2 specification chapter 8.3.7 says
      "For a session bean written to the EJB 3.x client view API, the transaction attributes are speci-
      fied for those methods of the session bean class that correspond to the bean’s business inter-
      face"
      Also the Javadoc for TransactionAttribute (http://docs.oracle.com/javaee/7/api/javax/ejb/TransactionAttribute.html) mention the bean class only.

              rstancel@redhat.com Radovan Stancel
              rhn-support-wfink Wolf Fink
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: