Search code examples
jbosswildfly-8

UserTransaction used by remote clients in WildFly


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!


Solution

  • It's now deprecated. Better use:

    UserTransaction ut = RemoteTransactionContext.getInstance().getUserTransaction();