Transaction problem in CMP and Session Bean
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Bart_Scheers
Posted On:   Wednesday, May 29, 2002 06:20 AM

Hi, This problem is bugging me way too long! In VAJ EE 4.0 I'm using two EJBs; bean A is CMP and B is a stateless SessionBean. Bean A has to insert (in its only ejbCreate) a record in table A in the database. To do so it first calls bean B's method that gets a valid id (this will be the primary key to be inserted into table A) out of table B. Furthermore, the same method then updates table B. In the debugger I can follow the variables. The right values are selected and updated (and commited) in table B by bean B. The right id (selected from table B and to be inserted into table A as a valid value) is then given to bean A as seen in the debugger. Then I assign those values. (getMethods give right results.) Bu   More>>

Hi,

This problem is bugging me way too long!

In VAJ EE 4.0 I'm using two EJBs; bean A is CMP and B is a stateless SessionBean.
Bean A has to insert (in its only ejbCreate) a record in table A in the database.
To do so it first calls bean B's method that gets a valid id (this will be the primary key to be inserted into table A) out of table B. Furthermore, the same method then updates table B.
In the debugger I can follow the variables. The right values are selected and updated (and commited) in table B by bean B. The right id (selected from table B and to be inserted into table A as a valid value) is then given to
bean A as seen in the debugger. Then I assign those values. (getMethods give right results.) But they're not inserted (or just not commited) into table A, in fact the transaction is rolled back. (When I leave out the call to the method of bean B and hard code the same value for the id at that position in bean A, the data is inserted (and commited) in table A.)
So, there is a transactionrolledbackexception when I use for both beans TX_REQUIRED (as they belong together), but apparently this is wrong.
(I cannot clearly discover if it is a VAJ generated EJSxxx-classes problem in some container instance or something else because insert in table B is not rolled back.)
What is going wrong that not all of the data is inserted or rolled back?
What attributes (if it's the attributes) do I have to use?

Thanks, so far
Bart Scheers

   <<Less

Re: Transaction problem in CMP and Session Bean

Posted By:   Mason_Taube  
Posted On:   Thursday, May 30, 2002 02:52 PM

Are these EJBs in different EJB Groups?


If so, try putting them both in the same ejb group (hold down control while highlighting them, then click on 'add to server').


I've been told that you can get around this problem by using a JTA JDBC driver but haven't tried that myself. Does anyone know how to get around this problem?? (In my case, I can't put all the EJBs in one group because they live in different databases)
About | Sitemap | Contact