dcsimg
java.lang.IllegalStateException: No transaction.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Saturday, November 3, 2001 01:19 AM

I have a JMS client, and I want to read a message from the queue and update an Oracle table in 1 transaction. I use SonicMQ as JMS broker. Curiously, I can't find a TransactionManager in SonicMQ, so I am using one from the jboss application server. Here is my code: TransactionManager tm = org.jboss.tm.TxManager.getInstance(); tm.begin(); Transaction transaction = tm.getTransaction(); // Some jdbc stuff String DATA_SOURCE_NAME = "jdbc:oracle:thin:"+username+"/"+password+"@"+host+":"+port+":"+sid; oracle.jdbc.xa.client.OracleXADataSource ds = new oracle.jdbc.xa.client.Oracl   More>>

I have a JMS client, and I want to read a message from the queue and update an Oracle table in 1 transaction. I use SonicMQ as JMS broker. Curiously, I can't find a TransactionManager in SonicMQ, so I am using one from the jboss application server. Here is my code:


TransactionManager tm = org.jboss.tm.TxManager.getInstance();


tm.begin();


Transaction transaction = tm.getTransaction();



// Some jdbc stuff


String DATA_SOURCE_NAME = "jdbc:oracle:thin:"+username+"/"+password+"@"+host+":"+port+":"+sid;


oracle.jdbc.xa.client.OracleXADataSource ds =
new oracle.jdbc.xa.client.OracleXADataSource();



ds.setDataSourceName("oracle.jdbc.xa.client.OracleXADataSource");


ds.setURL(DATA_SOURCE_NAME);


javax.sql.XAConnection conn = ds.getXAConnection();


c = conn.getConnection();


javax.transaction.xa.XAResource resource = conn.getXAResource();


/* the following line fails */


transaction.enlistResource(resource);


/* call procedure to update table
int result = insertCustomer(c,"14","15");


// jms stuff - it never gets here.
XAQueueConnectionFactory factory = (new progress.message.jclient.xa.XAQueueConnectionFactory (broker));
and so on.


On the enlistResource method, I have this error message:




java.lang.IllegalStateException: No transaction.
at org.jboss.tm.TransactionImpl.enlistResource(TransactionImpl.java:113)


If I comment out all the jdbc code, and just run the jms code in the transaction, it goes fine. I can enlist a resource with the jms xaresource.


Any help is greatly appreciated,

Michel de Lange

   <<Less
About | Sitemap | Contact