-
EJB Commit() & Rollback() not working (6 messages)
- Posted by: Suresh Dhandapani
- Posted on: January 09 2009 10:08 EST
Hi, We hava a J2EE application in WAS 6.0. We are using EJBs which calls a DAO layer. Oracle 10g is the backend and we use Oracle SPs for any CRUD operation. There is a save operation as part of our application which does multiple insert into multiple tables in different methods. There should be a rollback to happen on any exceptions or errors. We are using Session Beans(stateless) where the transactions are Container Managed and we rollback using setRollbackOnly() method of the Session Context. But we dont see any rollback happenning in case of exceptions, even though the setRollbackOnly() is called. Have anyone fixed this kind of error before? Thanks SureshThreaded Messages (6)
- Re: EJB Commit() & Rollback() not working by ishtiak sk on January 11 2009 02:23 EST
- Re: EJB Commit() & Rollback() not working by Suresh Dhandapani on January 11 2009 23:33 EST
- Re: EJB Commit() & Rollback() not working by Asiri Liyanage on January 11 2009 23:35 EST
- Re: EJB Commit() & Rollback() not working by Ignatius Joseph on January 13 2009 16:00 EST
- Re: EJB Commit() & Rollback() not working by Suresh Dhandapani on January 14 2009 23:27 EST
- Re: EJB Commit() & Rollback() not working by Yu Zhang on January 30 2009 11:25 EST
- Re: EJB Commit() & Rollback() not working by Suresh Dhandapani on January 14 2009 23:27 EST
-
Re: EJB Commit() & Rollback() not working[ Go to top ]
- Posted by: ishtiak sk
- Posted on: January 11 2009 02:23 EST
- in response to Suresh Dhandapani
I think it is the way you have handled JDBC connection. If you are calling SP, then I think you may have to look at possibility on setting autocommit as false, on the same connection used for calling SP. It is just a guess.... Thanks, Ishtiak http://interview-questions.weebly.com -
Re: EJB Commit() & Rollback() not working[ Go to top ]
- Posted by: Suresh Dhandapani
- Posted on: January 11 2009 23:33 EST
- in response to ishtiak sk
The autocommit is set to false in our case. We are creating connection as Connection conn = getConnection(">"); Connection myConn = (java.sql.Connection) WSJdbcUtil .getNativeConnection((WSJdbcConnection) conn); We do this as we are using oracle types oracle.sql.ARRAY and oracle.sql.ArrayDescriptor in our Stored procs. The connection object without type casting (in the second line above) is not supporting ARRAY and ArrayDescriptor. -
Re: EJB Commit() & Rollback() not working[ Go to top ]
- Posted by: Asiri Liyanage
- Posted on: January 11 2009 23:35 EST
- in response to Suresh Dhandapani
If you are using jndi look up to get a database connection, check whether you are using XA connection factory. -
Re: EJB Commit() & Rollback() not working[ Go to top ]
- Posted by: Ignatius Joseph
- Posted on: January 13 2009 16:00 EST
- in response to Suresh Dhandapani
Check the transaction attribute specified for those methods. Transaction attributes are specified for container managed transactions in ejb-jar.xml. For further information on transaction attributes please check the link below: http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Transaction3.html -
Re: EJB Commit() & Rollback() not working[ Go to top ]
- Posted by: Suresh Dhandapani
- Posted on: January 14 2009 23:27 EST
- in response to Ignatius Joseph
The transaction attribute is set to "Required". We identified that the issue was with the WsJdbcConnection that we use as part of the DAO layer. The DAO classes uses oracle.sql.ARRAY and oracle.sql.ArrayDescriptor to pass arrays to the Oracle SPs. The connection is created as below Connection conn = getConnection(>); OracleConnection myConn = (OracleConnection) WSJdbcUtil.getNativeConnection((WSJdbcConnection) conn); In ejb-jar.xml, the transaction attribute of the method submitCustomer is set to “Required”. Note – The rollback and commit are happening if java.sql.Connection is used. But java.sql.Connection cannot be used as it doesn’t accept oracle.sql.ARRAY and oracle.sql.ArrayDescriptor classes -
Re: EJB Commit() & Rollback() not working[ Go to top ]
- Posted by: Yu Zhang
- Posted on: January 30 2009 23:25 EST
- in response to Suresh Dhandapani
the problem is caused by the line below: OracleConnection myConn = (OracleConnection) WSJdbcUtil.getNativeConnection((WSJdbcConnection) conn); when you are using a native/physical connection instead of the wrapper connection provided by container, you will loss the transactional capability provided by XA datasource. this is because the wrapper connection knows when to enlist into a global transaction but the physical/native connection never knows this kind of information.