• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

An MDB calling an Entity bean

 
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting an error when the process leaves the onMessage() of the MDB. It is related to the entity bean that is trying to add a row to a cloudscape database.

"An illegal attempt to commit a one phase capable resource with existing two phase capable resources has occurred."

Phase? What are they refering to? I am using IBM MQ as my JMS service.

MDB code...

package mdbBeans;

import javax.ejb.CreateException;
import javax.jms.TextMessage;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
* Bean implementation class for Enterprise Bean: TaxMDB
*/
public class TaxMDBBean
implements javax.ejb.MessageDrivenBean, javax.jms.MessageListener {
private javax.ejb.MessageDrivenContext fMessageDrivenCtx;
/**
* getMessageDrivenContext
*/
public javax.ejb.MessageDrivenContext getMessageDrivenContext() {
return fMessageDrivenCtx;
}
/**
* setMessageDrivenContext
*/
public void setMessageDrivenContext(javax.ejb.MessageDrivenContext ctx) {
fMessageDrivenCtx = ctx;
}
/**
* ejbCreate
*/
public void ejbCreate() {
}
/**
* onMessage
*/
public void onMessage(javax.jms.Message msg) {
TextMessage tm = (TextMessage) msg;
String lmsg = tm.toString();

int len = lmsg.lastIndexOf("\n");
lmsg = lmsg.substring(len + 1);


System.out.println("Message received: " + lmsg);

int key;
key = Integer.parseInt(lmsg);
try {
InitialContext initialContext = new InitialContext();

TaxEjbEntityLocalHome TaxH = (TaxEjbEntityLocalHome)initialContext.lookup("java:comp/env/ejb/TaxEjbEntity");
TaxEjbEntityLocal tl = TaxH.create(key);
tl.setTaxName(("***" + key + "local" + "***"));
} catch (NamingException e) {

e.printStackTrace();
} catch (CreateException e) {

e.printStackTrace();
}

}
/**
* ejbRemove
*/
public void ejbRemove() {
}
}
 
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Here is a link that explains two phase commit.

http://www.jguru.com/faq/view.jsp?EID=20929

Regarding your problem-

If cloudscape jdbc provider that you are using supports two phase commit transaction.

I don't know much about cloudscape database but I found something about two phase and one phase commit which relates with the cloudscape jdbc provider that you might be using. Chances are that you might be using the one which supports one phase commit.
Here is the link from where I got this information:
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/rdat_minreq.html
 
M Burke
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the info. I do notice there are two drivers, on for one-phase and another for two-phase. The two-phase driver is called Cloudscape JDBC Provider (XA) com.ibm.db2j.jdbc.DB2jXADataSource. But I am not sure how to go about telling the system to use it in WAS
 
Damanjit Kaur
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I suppose you are using Weblogic Application Server (WAS). I found on following link some info about "When to Use a Tx Data Source" which is your case.
http://e-docs.bea.com/wls/docs70/adminguide/jdbc.html#jdbc002

and the second link specifies about configuring datasource.

http://e-docs.bea.com/wls/docs70/jdbc/programming.html#programming030
 
M Burke
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There doesn't seem to be a setting in Websphere to set the driver.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The entity bean is associated with a datasource. (It must be or nothing would work.)

I didn't catch if you are using WAS or WSAD. In WAS, you can set the datasource by drilling down to it under the resources link. In WSAD, you can set the datasource by clicking on the datasource tab of the server (in the servers perspective.)
 
Yes, my master! Here is the tiny ad you asked for:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic