1 Reply Latest reply on May 31, 2012 6:20 AM by canhhiep

    TransactionRequiredException: JBAS011469: Transaction is required to perform this operation

    canhhiep

      Hi,

       

      I have this exception when I am running my app in JBoss 7.1.1 Final:

       

      14:43:23,901 ERROR [stderr] (http--127.0.0.1-8080-2) Caused by: javax.persistence.TransactionRequiredException: JBAS011469: Transaction is required to perform this operation (either use a transaction or extended persistence context)

      14:43:23,903 ERROR [stderr] (http--127.0.0.1-8080-2)    at org.jboss.as.jpa.container.AbstractEntityManager.transactionIsRequired(AbstractEntityManager.java:692)

      14:43:23,904 ERROR [stderr] (http--127.0.0.1-8080-2)    at org.jboss.as.jpa.container.AbstractEntityManager.merge(AbstractEntityManager.java:547)

      14:43:23,907 ERROR [stderr] (http--127.0.0.1-8080-2)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      14:43:23,908 ERROR [stderr] (http--127.0.0.1-8080-2)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

      14:43:23,909 ERROR [stderr] (http--127.0.0.1-8080-2)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java

      :25)

      14:43:23,910 ERROR [stderr] (http--127.0.0.1-8080-2)    at java.lang.reflect.Method.invoke(Method.java:597)

      14:43:23,911 ERROR [stderr] (http--127.0.0.1-8080-2)    at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferen

      ceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)

      14:43:23,914 ERROR [stderr] (http--127.0.0.1-8080-2)    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      14:43:23,916 ERROR [stderr] (http--127.0.0.1-8080-2)    at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.jav

      a:374)

       

      I think this piece of code make exception is:

       

      public int getSomething() throws Exception {

                 try {

                      // this code make exception

                  } catch (NoSuchUserException x) {

                      //do nothing here

                  }

      }

       

      The excepion is already catch, and does not throw to the caller, but it seems that the transaction is marked as rollback, so transaction cannot be commited.

      The above code has worked fine in both JBoss 5 and 7.0.2, but in JBoss 7.1.1 Final the TransactionRequiredException is thrown and transaction fails. Could you please let me know how to config to make the transaction still exist in case exception happen but was catched ?.

       

      Thanks

      Hiep