When I start multiple EJB client threads at once, they sometimes get stuck during initialization. Reproducing example:
final static int THREADS = 25; (....) final ExecutorService pool = Executors.newFixedThreadPool(THREADS); for (int i = 0; i < THREADS; i++) { pool.submit(() -> { try { InitialContext ctx = new InitialContext(getCtxProperties()); String lookupName = "ejb:/server/HelloBean!ejb.HelloBeanRemote"; HelloBeanRemote bean = (HelloBeanRemote)ctx.lookup(lookupName); System.out.println(bean.hello()); ctx.close(); } catch (Exception e) { e.printStackTrace(); } }); } public static Properties getCtxProperties() { Properties props = new Properties(); props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); props.put("remote.connections", "main"); props.put("remote.connection.main.host", "127.0.0.1"); props.put("remote.connection.main.port", "8080"); props.put("remote.connection.main.username", "joe"); props.put("remote.connection.main.password", "joeIsAwesome2013!"); return props; }
So far I think it only affects scoped context. There seems to be some magic value, for THREADS=15 it works for me, but for THREADS=16 and more, all client threads get stuck during the EJB invocation with this stack:
Thread 7094: (state = BLOCKED) - java.lang.Object.wait(long) @bci=0 (Interpreted frame) - java.lang.Object.wait() @bci=2, line=502 (Interpreted frame) - org.jboss.ejb.client.EJBClientInvocationContext.awaitResponse(org.jboss.ejb.client.EJBInvocationHandler) @bci=159, line=588 (Interpreted frame) - org.jboss.ejb.client.EJBInvocationHandler.lambda$invoke$0(org.jboss.ejb.client.EJBClientContext, java.lang.Object, java.lang.Object[], org.jboss.ejb.client.EJBProxyInformation$ProxyMethodInfo, java.lang.reflect.Method, org.jboss.ejb.client.EJBReceiver, org.jboss.ejb.client.EJBLocator, org.jboss.ejb.client.Affinity) @bci=162, line=180 (Interpreted frame) - org.jboss.ejb.client.EJBInvocationHandler$$Lambda$124.execute(org.jboss.ejb.client.EJBReceiver, org.jboss.ejb.client.EJBLocator, org.jboss.ejb.client.Affinity) @bci=27 (Interpreted frame) - org.jboss.ejb.client.EJBClientContext.performLocatedAction(org.jboss.ejb.client.EJBLocator, org.jboss.ejb.client.EJBClientContext$LocatedAction) @bci=135, line=707 (Interpreted frame) - org.jboss.ejb.client.EJBInvocationHandler.invoke(java.lang.Object, org.jboss.ejb.client.EJBProxyInformation$ProxyMethodInfo, java.lang.Object[]) @bci=360, line=162 (Interpreted frame) - org.jboss.ejb.client.EJBInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]) @bci=44, line=112 (Interpreted frame) - com.sun.proxy.$Proxy2.echo(java.lang.String) @bci=16 (Interpreted frame) - com.redhat.qe.ejbperf.ClientThreadStateless.run() @bci=320, line=83 (Interpreted frame)
This is a regression in client from EAP 7.1.0.DR17, I don't see this with any previous build.
- is related to
-
JBEAP-12076 (7.1.z) Client gets stuck when invoking EJBs in multiple threads when using old remote-naming API
- Closed