Combining BMP and CMP within a Transaction in a session bean (facade)

M

Mick Willis

I am having trouble mixing calls to BMP and CMP entity beans within
the same method call in a session bean.

I have a number of CMP beans but I needed to create one BMP bean in
order to implement some Oracle specfic SQL code (using XMLType CLOB).
However, as the BMP needed to obtain its own connection an error was
throw which indicates that two connections are not allowed within the
transaction without resorting to XA datasource for 2 phase commit. I
don't want to do this.

I have tried changing the session bean to be "bean managed" trasaction
and this allows the BMP to be called successfully, but then a
subsequent calls to CMP beans results in a
java.lang.IllegalStateException. Code snipit below:

// ScheduleTaskLocal is a CMP
ScheduleTaskLocal schTk = (ScheduleTaskLocal) i.next();
System.out.println("Schedule Task # " + schTk.getPrimaryKey());

// get schedule run details (this is BMP bean)
ScheduleRunDetailLocal taskDet = null;
try {

taskDet = getScheduleRunDetailHome().findByPrimaryKey(
new ScheduleRunDetailKey((Integer) schedRun.getPrimaryKey(),
(Integer) schTk.getPrimaryKey()));

} catch (FinderException e) {

// not been started yet so check for dependancies
Collection tkDepCol = schTk.getTaskdependancy();

Iterator tkIter = tkDepCol.iterator(); // <-- error here with
IllegalStateException

....


Any ideas or people with similar problems. Thanks in advance.
 
S

Sudsy

Mick Willis wrote:
However, as the BMP needed to obtain its own connection an error was
throw which indicates that two connections are not allowed within the
transaction without resorting to XA datasource for 2 phase commit. I
don't want to do this.
<snip>

Why? The XA drivers are available in classes111.zip and classes12.zip.
All you'd need to do is change your DataSource in the J2EE server to
oracle.jdbc.xa.OracleXADataSource.
It might take a bit of effort to make it work but it's worthwhile IMHO.
The equivalent class for DB/2 is COM.ibm.db2.jdbc.DB2XADataSource.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top