Hi,
I am having problems in Jboss ( 4.2.3 ) when using jndi to lookup the UserTransaction, depending on my client. Firstly I had a successful junit test running in an OpenEJB container. This would get the UserTransaction object from my jboss server, then I could begin a transaction and perform some operation on that server using an EJB (Remote) interface. Then using the UserTransaction I could either commit or rollback the changes made on the jboss server by the EJB call , from the client. No problem. However the very same code does not work when my client code sits inside another Jboss (4.2.3) Container. A snippet of my client code and investigation is given below.
Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.NamingContextFactory");
properties.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming.client:org.jnp.interfaces");
properties.setProperty(Context.PROVIDER_URL, "someIpAddress:1099");
Context ctx = new InitialContext(properties);
userTx = (ClientUserTransaction) ctx.lookup("UserTransaction");
// now do userTx.begin(), userTx.rollback(), userTxCommit() etc..
This code works in OpenEJB and the object I am getting back in actually a org.jboss.tm.usertx.client.ClientUserTransaction
However I found that when run inside Jboss the lookup returns a
org.jboss.tm.usertx.client.ServerVMClientUserTransaction
This UserTransaction instance cannot be used to successfully .begin() , rollback() and commit() the remote transaction. I can see through the jmx console that ClientUserTransaction appears to be avialable in the jndi tree just as I have looked it up from OpenEJB without Issue.
The question is how can I get a reference to the ClientUserTransaction object I need from within another Jboss container, and is it even possible?
I am sure I am missing something. Thanks for any help.