Multiple threads on client side for remote EJB calls on Jboss7
danjee Sep 28, 2015 3:39 PMHello
I am using JBoss EAP 6.4.0.GA (AS 7.5.0.Final-redhat-21) to deploy an ear that contains some stateless ejb 3.
My problem is in the client side:
public class TestJndi {
public static void main(final String[] args) throws AppException {
final Hashtable env = new Hashtable();
env.put("java.naming.factory.initial", "org.jboss.naming.remote.client.InitialContextFactory");
env.put("java.naming.provider.url", "remote://localhost:4447");
env.put("java.naming.security.credentials", "c4ca4238a0b923820dcc509a6f75849b");
env.put("java.naming.security.principal", "capone");
env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
env.put("jboss.naming.client.ejb.context", "true");
env.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
env.put("org.jboss.ejb.client.scoped.context", "true");
try {
InitialContext ctx = new InitialContext(env);
final SecurityController o = (SecurityControllerRemote) ctx.lookup(
"ejb:agency-ear/agency-ejb/SecurityControllerBean!ro.asf.capone.ejb.beans.security.SecurityControllerRemote");
System.out.println("1outcome: " + o.getServerTimeMillis());
new Thread(new Runnable() {
@Override
public void run() {
System.out.println("2outcome: " + o.getServerTimeMillis());
}
}).start();
} catch (final NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
The output for this is:
1outcome: 1443468729846 java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:agency-ear, moduleName:agency-ejb, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@4fc064ca at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:754) at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:116) at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:186) at org.jboss.ejb.client.EJBInvocationHandler.sendRequestWithPossibleRetries(EJBInvocationHandler.java:253) at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:198) at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:181) at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:144) at com.sun.proxy.$Proxy2.getServerTimeMillis(Unknown Source) at com.asf.capone.client.util.TestJndi$1.run(TestJndi.java:40) at java.lang.Thread.run(Thread.java:745)
I need the multithreading because it's a swing application. Is it a configuration issue? Thank you!