6 Replies Latest reply on Jul 31, 2013 10:23 AM by daviwebe

    "java.lang.IllegalStateException: No EJB receiver available for handling" for only some beans during an EJB method invocation from a remote client using JNDI

    daviwebe

      I am migrating an application from a JBoss 4.2.3.GA to a JBoss AS 7.1.1.Final. After numerous adaptations I managed to get the application running but I have remaining problems with the invocation of methods of some beans.

      Several beans are deployed on a JBoss AS 7.1.1.Final within an .ear and I connect to the server from a remote client using JNDI.

       

      The context lookup for the beans seems to be no problem but the method invocation on some beans ends up in the following exception:

       

      {code}

      java.lang.IllegalStateException: No EJB receiver available for handling [appName:EnterpriseApplication1,modulename:EJBModule3,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@76b0852c

          at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584)

          at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:119)

          at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)

          at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)

          at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)

          at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)

          at com.sun.proxy.$Proxy12.getNativeSQLSingleFoodList(Unknown Source)

          at ch.ethz.inf.foodcomp.client.gui.singlevalue.SingleFoodTablePanel.getNativeSQLList(SingleFoodTablePanel.java:157)

          at ch.ethz.inf.foodcomp.lib.table.AbstractTablePanel.refreshImplemented(AbstractTablePanel.java:417)

          at ch.ethz.inf.foodcomp.lib.table.AbstractTablePanel.refresh(AbstractTablePanel.java:334)

          at ch.ethz.inf.foodcomp.client.gui.singlevalue.SingleValueTab$RefreshTask.doInBackground(SingleValueTab.java:178)

          at org.jdesktop.swingworker.SwingWorker$1.call(Unknown Source)

          at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)

          at java.util.concurrent.FutureTask.run(FutureTask.java:166)

          at org.jdesktop.swingworker.SwingWorker.run(Unknown Source)

          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

          at java.lang.Thread.run(Thread.java:724)

      {code}

       

       

      For some beans the method invocation works but for others not. The failing beans are always the same ones.

      Therefore, I show here always code snippets for a bean where the method invocation is working (ReferenceBean.getSQLReferences()) and for a bean where the method invocation is not working (SingleFoodBean.getNativeSQLSingleFoodList()).

       

      While debugging I see that it is possible to get the beans but on the code line where the method invocation takes place the exception is thrown.

       

      When I create a simple client application and copy my configuration from the original one I can invoke the method SingleFoodBean.getNativeSQLSingleFoodList() on the same deployment without any problems with the expected result.

      I see no difference in the invocations for the different beans and therefore I would appreciate any ideas or comments on this issue.

      If I have forgotten to provide any necessary information please ask for it.

       

       

      ----

      Following, some detail information.

       

      Both beans are deployed successfully as one can see in the server log:

       

      {code}

      12:48:27,131 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-4) JNDI bindings for session bean named ReferenceBean in deployment unit subdeployment "EJBModule3.jar" of deployment "EnterpriseApplication1.ear" are as follows:

       

          java:global/EnterpriseApplication1/EJBModule3/ReferenceBean!ch.ethz.inf.foodcomp.lib.sessioninterfaces.ReferenceRemote

          java:app/EJBModule3/ReferenceBean!ch.ethz.inf.foodcomp.lib.sessioninterfaces.ReferenceRemote

          java:module/ReferenceBean!ch.ethz.inf.foodcomp.lib.sessioninterfaces.ReferenceRemote

          java:jboss/exported/EnterpriseApplication1/EJBModule3/ReferenceBean!ch.ethz.inf.foodcomp.lib.sessioninterfaces.ReferenceRemote

          java:global/EnterpriseApplication1/EJBModule3/ReferenceBean

          java:app/EJBModule3/ReferenceBean

          java:module/ReferenceBean

       

       

      12:48:27,289 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-4) JNDI bindings for session bean named SingleFoodBean in deployment unit subdeployment "EJBModule3.jar" of deployment "EnterpriseApplication1.ear" are as follows:

       

          java:global/EnterpriseApplication1/EJBModule3/SingleFoodBean!ch.ethz.inf.foodcomp.lib.sessioninterfaces.SingleFoodRemote

          java:app/EJBModule3/SingleFoodBean!ch.ethz.inf.foodcomp.lib.sessioninterfaces.SingleFoodRemote

          java:module/SingleFoodBean!ch.ethz.inf.foodcomp.lib.sessioninterfaces.SingleFoodRemote

          java:jboss/exported/EnterpriseApplication1/EJBModule3/SingleFoodBean!ch.ethz.inf.foodcomp.lib.sessioninterfaces.SingleFoodRemote

          java:global/EnterpriseApplication1/EJBModule3/SingleFoodBean

          java:app/EJBModule3/SingleFoodBean

          java:module/SingleFoodBean

      {code}

       

       

      The server is starting with the deployed .ear without any error messages.

       

      I do not use a jboss-ejb-client.properties file. The configuation is done in the code in the class BeanBag that also handles the access to the beans:

       

      {code:java}

          private BeanBag(String username, String md5, String providerURL, boolean useCache) throws FileNotFoundException, IOException, NamingException {

              Properties config = new Properties();

              BeanBag.username = username;

       

              config.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

              config.put(Context.SECURITY_PRINCIPAL, username);

              config.put(Context.SECURITY_CREDENTIALS, md5);

              config.put("jboss.naming.client.ejb.context", true);

              config.put(Context.PROVIDER_URL, "remote://localhost:4447");

              config.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");

              config.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

       

              // get the entity provider

              context = new InitialContext(config);

          }

      {code}

       

       

      The two beans with the appropriate methods:

       

      {code:java}

      @Stateless

      @Remote(ReferenceRemote.class)

      public class ReferenceBean implements ReferenceRemote {

       

          @PersistenceContext(unitName = "fcdb")

          private EntityManager em;

      ...

          @Override

          public ArrayList<Object[]> getSQLReferences() {

              Query query = em.createNativeQuery("SELECT * FROM qryreferences");

              return (ArrayList<Object[]>) query.getResultList();

          }

      ...

      }

       

       

      @Stateless

      @Remote(SingleFoodRemote.class)

      public class SingleFoodBean implements SingleFoodRemote {

       

          @PersistenceContext(unitName = "fcdb")

          private EntityManager em;

      ...

          @Override

          public ArrayList<Object[]> getNativeSQLSingleFoodList() {

              try {

                  Query query = em.createNativeQuery("SELECT * FROM qrysinglefoodlist");

                  return (ArrayList<Object[]>) query.getResultList();

              } catch (Exception e) {

                  logger.log(Level.SEVERE, e.getMessage());

                  return null;

              }

          }

      ...

      }

      {code}

       

      There are also beans for which the invocation is working that have additional annotations like:

       

      {code:java}

      @SecurityDomain("FoodCASE")

      @DeclareRoles({"admin", "compiler", "readOnly"})

      {code}

       

      But this seems not to be the issue since there are beans for which the invocation is working that have the same annotations as the non working.

       

      The remote views:

       

      {code:java}

      @Remote

      public interface ReferenceRemote {...}

       

      @Remote

      public interface SingleFoodRemote {...}

      {code}

       

       

      Bean lookup in the BeanBag class:

       

      {code:java}

      String REFERENCE_BEAN_REMOTE = "ejb:EnterpriseApplication1/EJBModule3/ReferenceBean!ch.ethz.inf.foodcomp.lib.sessioninterfaces.ReferenceRemote";

      String SINGLE_FOOD_BEAN_REMOTE = "ejb:EnterpriseApplication1/EJBModule3/SingleFoodBean!ch.ethz.inf.foodcomp.lib.sessioninterfaces.SingleFoodRemote";

       

      ...

          public static ReferenceRemote getReferenceBean() {

              if (referenceRemote == null) {

                  try {

                      referenceRemote = (ReferenceRemote) context.lookup(REFERENCE_BEAN_REMOTE);

                  } catch (NamingException ex) {

                      logger.log(Level.SEVERE, ex.getMessage());

                  }

              }

              return referenceRemote;

          }

       

          public static SingleFoodRemote getSingleFoodBean() {

              if (singleFoodRemote == null) {

                  try {

                      singleFoodRemote = (SingleFoodRemote) context.lookup(SINGLE_FOOD_BEAN_REMOTE );

                  } catch (NamingException ex) {

                      logger.log(Level.SEVERE, ex.getMessage());

                  }

              }

              return singleFoodRemote;

          }

      {code}

       

      Bean method usage (in the client)

      For the ReferenceBean in the GUI class ReferenceTablePanel

       

      {code:java}

          @Override

          public List<Object[]> getNativeSQLList() {

              return BeanBag.getReferenceBean().getSQLReferences();

          }

      {code}

       

      For the SingleFoodBean in the GUI class SingleFoodTablePanel:

       

       

      {code:java}

          @Override

          public List<Object[]> getNativeSQLList() {

              return BeanBag.getSingleFoodBean().getNativeSQLSingleFoodList();

          }

      {code}

       

       

      In the server log (see attachment) there is no helpful log statement even though it is on TRACE level.