2

Is it possible to lookup and use UserTransaction from a remote-client as in AS 4?

I followed this document and connected from outside the server: Remote EJB invocations via JNDI - EJB client API or remote-naming project - WildFly 8 - Project Documentation Editor.

Here is the code that I used in AS 4, which failed in WildFly

Eg:

public void beginTransaction() {
    try {
        ut = (UserTransaction) getCtx().lookup("UserTransaction");
        ut.begin();
    } catch (Exception ex) {
        throw new RuntimeException("Failed to begin UserTransactiion", ex);
    }
}

Then I got this error:

Caused by: javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.jboss.exported.UserTransaction

Thanks!

Valsaraj Viswanathan
  • 1,473
  • 5
  • 28
  • 51
  • Do you now have an solution on this? I am looking for it – Johnny2012 Jul 08 '15 at 11:11
  • I started the wildfly server with the option -Djboss.node.name=node1 to make the EJBClient.getUserTransaction() method happy. UserTransaction ut = EJBClient.getUserTransaction("node1"); This worked for me. – Valsaraj Viswanathan Jul 10 '15 at 06:59

1 Answers1

3

It's now deprecated. Better use:

UserTransaction ut = RemoteTransactionContext.getInstance().getUserTransaction();
slfan
  • 8,950
  • 115
  • 65
  • 78