[jboss-user] [EJB3] - 'You cannot commit during a managed transaction' issue

Catalin Moga do-not-reply at jboss.com
Thu Apr 21 03:07:39 EDT 2011


Catalin Moga [http://community.jboss.org/people/mcatalin23] created the discussion

"'You cannot commit during a managed transaction' issue"

To view the discussion, visit: http://community.jboss.org/message/601302#601302

--------------------------------------------------------------
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.
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/601302#601302]

Start a new discussion in EJB3 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110421/7c0c2bab/attachment-0001.html 


More information about the jboss-user mailing list