Client application trying to invoke EJB in the same VM during deployment and getting EJBCLIENT000079: Unable to discover destination in JBoss EAP 7
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 7
Issue
- Client application trying to invoke EJB in the same VM during deployment and getting EJBCLIENT000079: Unable to discover destination in JBoss EAP 7
14:43:25,079 INFO [com.redhat.examples.servlet.Servlet] (ServerService Thread Pool -- 72) Trying to call: ejb:initialize-in-order-ejb-remote/A/EE6ExampleSingleton!com.jboss.examples.ejb.ExampleRemote
14:43:25,085 INFO [org.wildfly.naming] (ServerService Thread Pool -- 72) WildFly Naming version 1.0.10.Final-redhat-00001
14:43:25,103 ERROR [stderr] (ServerService Thread Pool -- 72) javax.ejb.NoSuchEJBException: EJBCLIENT000079: Unable to discover destination for request for EJB StatelessEJBLocator for "initialize-in-order-ejb-remote/A/EE6ExampleSingleton", view is interface com.jboss.examples.ejb.ExampleRemote, affinity is None
14:43:25,103 ERROR [stderr] (ServerService Thread Pool -- 72) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:607)
14:43:25,104 ERROR [stderr] (ServerService Thread Pool -- 72) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:543)
14:43:25,104 ERROR [stderr] (ServerService Thread Pool -- 72) at org.jboss.ejb.protocol.remote.RemotingEJBClientInterceptor.handleInvocationResult(RemotingEJBClientInterceptor.java:56)
14:43:25,104 ERROR [stderr] (ServerService Thread Pool -- 72) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:609)
14:43:25,104 ERROR [stderr] (ServerService Thread Pool -- 72) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:543)
14:43:25,104 ERROR [stderr] (ServerService Thread Pool -- 72) at org.jboss.ejb.client.TransactionPostDiscoveryInterceptor.handleInvocationResult(TransactionPostDiscoveryInterceptor.java:148)
14:43:25,104 ERROR [stderr] (ServerService Thread Pool -- 72) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:609)
14:43:25,104 ERROR [stderr] (ServerService Thread Pool -- 72) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:543)
14:43:25,105 ERROR [stderr] (ServerService Thread Pool -- 72) at org.jboss.ejb.client.DiscoveryEJBClientInterceptor.handleInvocationResult(DiscoveryEJBClientInterceptor.java:124)
14:43:25,105 ERROR [stderr] (ServerService Thread Pool -- 72) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:609)
14:43:25,105 ERROR [stderr] (ServerService Thread Pool -- 72) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:543)
14:43:25,105 ERROR [stderr] (ServerService Thread Pool -- 72) at org.jboss.ejb.client.NamingEJBClientInterceptor.handleInvocationResult(NamingEJBClientInterceptor.java:85)
14:43:25,105 ERROR [stderr] (ServerService Thread Pool -- 72) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:609)
14:43:25,105 ERROR [stderr] (ServerService Thread Pool -- 72) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:543)
14:43:25,105 ERROR [stderr] (ServerService Thread Pool -- 72) at org.jboss.ejb.client.TransactionInterceptor.handleInvocationResult(TransactionInterceptor.java:212)
14:43:25,106 ERROR [stderr] (ServerService Thread Pool -- 72) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:609)
14:43:25,106 ERROR [stderr] (ServerService Thread Pool -- 72) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:543)
14:43:25,106 ERROR [stderr] (ServerService Thread Pool -- 72) at org.jboss.ejb.client.EJBClientInvocationContext.awaitResponse(EJBClientInvocationContext.java:963)
14:43:25,106 ERROR [stderr] (ServerService Thread Pool -- 72) at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:191)
14:43:25,106 ERROR [stderr] (ServerService Thread Pool -- 72) at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:125)
14:43:25,106 ERROR [stderr] (ServerService Thread Pool -- 72) at com.sun.proxy.$Proxy66.hello(Unknown Source)
14:43:25,107 ERROR [stderr] (ServerService Thread Pool -- 72) at com.redhat.examples.servlet.Servlet.testExampleRemote(Servlet.java:50)
Resolution
The client application is trying to invoke the EJB that is in the same VM by invoking it over the network. Since JBoss EAP is not started yet, it is not accepting external requests (which is the EAP 7 graceful shutdown and suspended start functionality preventing external requests before everything is up and running).
Options
Invoke the EJB internally
The solution is to invoke the EJB using the java:global/... EJB binding which are in VM and can be used to invoke the EJB's remote or local interface without going over the network.
Another solution is to do lazy loading and not try to invoke the EJB at deployment time, but invoke it when an external request comes into the application.
Register an MBean Notification Listener to run a callback once JBoss is started
See: How to invoke code when JBoss EAP 7 is fully started
EAP 7.4 +
How to disable graceful startup and allow external invocations before JBoss EAP 7.4 is started
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.