EJBCLIENT000045: User transactions not supported by this context in JBoss EAP 6.4
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 6.4
Issue
- We are getting this error trying to use UserTransaction from one EAP 6.4 server calling an EJB on another EAP 6.4 server using the server to server configuration.
ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/client].[Faces Servlet]] (http-127.0.0.1:8080-1) JBWEB000236: Servlet.service() for servlet Faces Servlet threw exception: java.lang.IllegalStateException: EJBCLIENT000045: User transactions not supported by this context
at org.jboss.ejb.client.EJBClientTransactionContext.getUserTransaction(EJBClientTransactionContext.java:138) [jboss-ejb-client-1.0.41.Final-redhat-1.jar:1.0.41.Final-redhat-1]
at org.jboss.ejb.client.EJBClient.getUserTransaction(EJBClient.java:265) [jboss-ejb-client-1.0.41.Final-redhat-1.jar:1.0.41.Final-redhat-1]
at com.jboss.examples.ejb3.gui.BackingBean.helloWithUtx(BackingBean.java:84) [classes:]
import org.jboss.ejb.client.EJBClient;
import javax.transaction.UserTransaction;
...
Properties props = new Properties();
props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
Context context = new InitialContext(props);
UserTransaction utx=EJBClient.getUserTransaction("yourServerName");
...
utx.begin();
Resolution
When the client is running in JBoss EAP , lookup the UserTransaction from java:jboss/UserTransaction or java:comp/UserTransaction such as:
import java.util.Properties;
import javax.naming.InitialContext;
import javax.transaction.UserTransaction;
...
Properties props = new Properties();
props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
Context context = new InitialContext(props);
UserTransaction utx = (UserTransaction) context.lookup("java:jboss/UserTransaction");
...
utx.begin();
Root Cause
Using EJBClient.getUserTransaction(...) inside of JBoss EAP, instead of looking up java:jboss/UserTransaction or java:comp/UserTransaction
Components
Category
Tags
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.