I have a stateless session bean with container-managed transactions. In one of the business methods, the first
thing I do is create an entity bean (bean-managed persistance). In trying to test the transaction mechanism, I immediately throw an EJBException to see that the entity bean create is rolled-back. In the server log, I can see that a rollback happened, but the entity data is indeed stored in the database.
Can someone tell me when to start looking. I am using Weblogic 5.1 and have reviewed their documentation and the EJB spec and cannot find anything that explains this behavior.
Thanks in advance for your help.
Discussions
EJB programming & troubleshooting: EJB Container-Managed Transaction Creating Entity Bean
-
EJB Container-Managed Transaction Creating Entity Bean (6 messages)
- Posted by: Katherine Walker
- Posted on: July 11 2000 17:12 EDT
Threaded Messages (6)
- EJB Container-Managed Transaction Creating Entity Bean by Kumar Mettu on July 11 2000 18:18 EDT
- EJB Container-Managed Transaction Creating Entity Bean by Katherine Walker on July 12 2000 14:35 EDT
-
EJB Container-Managed Transaction Creating Entity Bean by Floyd Marinescu on July 12 2000 09:12 EDT
-
EJB Container-Managed Transaction Creating Entity Bean by Jean-Baptiste Nizet on July 13 2000 05:47 EDT
- EJB Container-Managed Transaction Creating Entity Bean by Katherine Walker on July 13 2000 01:39 EDT
-
EJB Container-Managed Transaction Creating Entity Bean by Jean-Baptiste Nizet on July 13 2000 05:47 EDT
- EJB Container-Managed Transaction Creating Entity Bean by Ivan Likhachov on March 01 2001 12:41 EST
-
EJB Container-Managed Transaction Creating Entity Bean by Floyd Marinescu on July 12 2000 09:12 EDT
- EJB Container-Managed Transaction Creating Entity Bean by Katherine Walker on July 12 2000 14:35 EDT
-
EJB Container-Managed Transaction Creating Entity Bean[ Go to top ]
- Posted by: Kumar Mettu
- Posted on: July 11 2000 18:18 EDT
- in response to Katherine Walker
hi Katherine,
I faced the same problem many a times. But for me this happens only with first create call.
(ofcourse I am also using wls5.1)
Regards,
Mettu. -
EJB Container-Managed Transaction Creating Entity Bean[ Go to top ]
- Posted by: Katherine Walker
- Posted on: July 12 2000 14:35 EDT
- in response to Kumar Mettu
Thanks for you input. It is nice to know others are having the same problem.
Just wanted to let everyone know that I corrected the problem. JDBC has autoCommit set to true by default and thus you cannot rollback a transaction. Perhaps others are having the same problem. When I used conn.setAutoCommit(false) the rollback was successful.
Katherine -
EJB Container-Managed Transaction Creating Entity Bean[ Go to top ]
- Posted by: Floyd Marinescu
- Posted on: July 12 2000 21:12 EDT
- in response to Katherine Walker
When I used conn.setAutoCommit(false) the rollback was successful.
Katherine, that is indeed weird! You would think that the container would be smart enough to manage things like that. Perhaps there is some sort of deployment descriptor flag that needs to be set or something like that...
Floyd -
EJB Container-Managed Transaction Creating Entity Bean[ Go to top ]
- Posted by: Jean-Baptiste Nizet
- Posted on: July 13 2000 05:47 EDT
- in response to Floyd Marinescu
That's weird, indeed.
However, Katherine didn't mention if its bean was a CMP bean and, if it was, how she got the connection.
If she correctly used the datasource/connection pool mechanism, or if the bean was CMP, then it's a bug (and an important one) in WLS.
Else, if she used DriverManager.getConnection(), she probably bypassed the container mechanism, and got a connection with autocommit set to true.
JB. -
EJB Container-Managed Transaction Creating Entity Bean[ Go to top ]
- Posted by: Katherine Walker
- Posted on: July 13 2000 13:39 EDT
- in response to Jean-Baptiste Nizet
The entity bean has BMP and creates the connection using the DataSource method.
Katherine -
EJB Container-Managed Transaction Creating Entity Bean[ Go to top ]
- Posted by: Ivan Likhachov
- Posted on: March 01 2001 12:41 EST
- in response to Katherine Walker
The idea is very interesting. The Rollback works fine, if some exception happens. But after setAutoCommit(false) my data didn't store in DB. Server log showed, that transaction was well and commited by server.