3 Replies Latest reply on Apr 21, 2011 3:41 AM by jaikiran

    'You cannot commit during a managed transaction' issue

    mcatalin23

      I'm using Jboss 6 and Ejb 3.1.

      Session beans are deployed into jboss using deplyment descriptor xml-jar.xml.

      The client is calling ejb methods using lookup:

      MyInterface sessionService = (MyInterface) namingContext.lookup(appname + MyBean.class.getSimpleName() + "/remote");

       

      The connection works well but I have an issue with the transaction while calling commit, rollback...:

       

       

      java.sql.SQLException: You cannot commit during a managed transaction!

          at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.jdbcCommit(BaseWrapperManagedConnection.java:661)

          at org.jboss.resource.adapter.jdbc.WrappedConnection.commit(WrappedConnection.java:496)

          at com.....MyBeanClass.MyBeanMethod(MyBeanClass.java:328)

       

       

      I've read that "by default enterprise beans use container-managed transactions. Enterprise beans that use container-managed transaction demarcation must not use any transaction management methods that interfere with the container’s transaction demarcation boundaries. Examples of such methods are the commit, setAutoCommit, and rollback. If you require control over the transaction demarcation, you must use application-managed transaction demarcation."

       

      The idea is that I want to use manually commit, rollback... but I don't know how. Is the information above the right direction for what I need? Should I use application managed transactions instead of container managed transactions which is default? How can I do this? Any documentation on this would help too. Thank you.