4 Replies Latest reply on Jul 9, 2018 10:38 AM by Greg Jewell

    Lookup of stateful session bean from second application in same Wildfly instance

    Christian Kölle Newbie



      I have a problem with calling a stateful session bean remotely from another application deployed in the same Wildfly (12.0.0.Final) instance.


      The first application (backend application) contains the stateful bean:


      package ch.nic.reg.backend;


      import javax.ejb.Stateful;


      import ch.nic.reg.common.BackendRemote;



      public class EPPBackendBean implements EPPBackendRemote {


           public String getSessionId() throws Exception {

                return "NewSessionId123";




      The bean is inside an ejb-jar and packed in an ear. The ear deploys fine in the server:



      08:43:14,778 INFO  [org.jboss.as.ejb3.deployment] (MSC service thread 1-5) WFLYEJB0473: JNDI bindings for session bean named 'BackendBean' in deployment unit 'subdeployment "backend.jar" of deployment "backend.ear"' are as follows:










      The second application (frontend application) has a singleton bean which calls the backend bean:




      public class Frontend {



      public void start() {

           InitialContext context = null;

           Backend remote = null;

           try {

           Map<String, String> environment = new Hashtable<>();

           environment.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");


           context = new InitialContext((Hashtable<String, String>) environment);

           remote = (BackendRemote) context.lookup("ejb:backend/backend/BackendBean!ch.nic.reg.common.BackendRemote?stateful");

           } catch (Exception e) {






      In order to ensure that the backend is deployed before the singleton bean starts we have a dependency between the two deploments defined in jboss-all.xml in frontend ear:


      <jboss umlns="urn:jboss:1.0">

           <jboss-deployment-dependencies xmlns="urn:jboss:deployment-dependencies:1.0">

                <dependency name="reg-epp-backend-client.ear" />




      Additionaly the frontend ear has also a wildfly-config.xml:



          <authentication-client xmlns="urn:elytron:1.0">


                          <rule use-configuration="default" />



                  <configuration name="default">

                      <sasl-mechanism-selector selector="#ALL" />


                          <property key="wildfly.sasl.local-user.quiet-auth" value="true" />










      Here's the error message:


      08:43:19,915 ERROR [stderr] (ServerService Thread Pool -- 75) javax.naming.CommunicationException: EJBCLIENT000062: Failed to look up "backend/backend/BackendBean!ch.nic.reg.common.BackendRemote?stateful" [Root exception is org.jboss.ejb.client.RequestSendFailedException: EJBCLIENT000409: No more destinations are available]

      08:43:19,916 ERROR [stderr] (ServerService Thread Pool -- 75) at org.jboss.ejb.client.EJBRootContext.lookupNative(EJBRootContext.java:160)


      08:43:19,925 ERROR [stderr] (ServerService Thread Pool -- 75) Caused by: org.jboss.ejb.client.RequestSendFailedException: EJBCLIENT000409: No more destinations are available

      08:43:19,925 ERROR [stderr] (ServerService Thread Pool -- 75) at org.jboss.ejb.client.NamingEJBClientInterceptor.handleSessionCreation(NamingEJBClientInterceptor.java:100)


      If i try to lookup the backend bean from a standalone EJB client with the exact same lookup code it works perfectly.


      Any ideas what's the difference?