4 Replies Latest reply on Mar 25, 2013 9:49 AM by mannu_cse

    How to find if the EJB Proxy object is stale and no longer bound to actual bean in the server

    mannu_cse

      We have a cluster of jboss nodes and a service is deployed in these nodes, this service contains a stateless bean which is clustered

       

      There is a client which makes a JNDI lookup and invoked the EJB method.

      we make the JNDI lookup at the begining and then invoke the method in future a number of times.

       

      in one case the target service is undeployed from one of the node, which results in

      java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:ServerTestService-1.0.1, moduleName:ServerTestEJB-1.0.1, distinctName:] combination for invocation context

       

      What we want is in case the EJB Proxy object is stale ( i.e. bound connection is closed due to service undeployed) we want the proxy object to make a fresh JNDI lookup and bind to another available EJB in the cluster.

       

      Is there any way to find if the object is stale

       

      InitialContext context = null;

               try {

                   context = new InitialContext(properties);

                   Object ejbObject = context.lookup(jndiName); // here lookup succeeds

                   ((ServiceIf) ejbObject ).call(); // making some ejb method call which succeeds

                   // wait for some time and service bound to ejbObject might be removed, now make another method call

                   if( ejbObject still bound .... dont know how to find this )

                   {

                        ((ServiceIf) ejbObject ).anotherCall();

                   }

                    else

                   {

                          // make a fresh JNDI lookup from the cluster

                          ejbObject = context.lookup(jndiName);

                          ((ServiceIf) ejbObject ).anotherCall();

                   }

       

               } catch (final Exception exc) {

                   LOG.error("Exception while looking up/executing bean with JNDI {}. Details: {}", jndiName, exc.getMessage());

                   throw exc;

               }