0 Replies Latest reply on Oct 25, 2016 7:54 PM by thinksteep thinksteep

    Wildfly 8.2 remote-naming context reuse

    thinksteep thinksteep Novice

      Hi Team,

       

      We are having an interesting issue with EJB lookp. We are re-using context and resetting in case of lookup exception and get the new context. Some how this is becoming stale and failing with following exception.

       

      EJBCLIENT000025: No EJB receiver available for handling

       

      This is happening specifically in case where Wildfly restarted but NOT the client. Once we restart the client everything back to normal till next time Wildfly goes down.

       

      We are calling .close() but it seems this is not releasing the context and somehow becoming stale. We appreciate any help on this issue.

       

      The reason why we are caching context is, this client deals heavy load, so repeat context creation could be costly.

       

      Code:

      public class SomeClass {

       

      private static Context context;

      public void someMethod()

      {

       

      try {

                      if(context == null)

                      {

                       Properties props = new Properties();

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

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

                      props.put(Context.PROVIDER_URL, "http-remoting://IP:8080");

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

                      props.put(Context.SECURITY_PRINCIPAL, "username");

                      props.put(Context.SECURITY_CREDENTIALS, "pwd");

                      context = new InitialContext(props);

                      }

                  BeanRemote beanRemote = (BeanRemote) context.lookup("AppName/ModuleName//Bean!com.test.test2.BeanRemote");

                  long val = beanRemote.getLatestvalue(88);

              } catch (Exception e) {

                  try {

                      context.close();

                  } catch (Exception e2) {

                         e2.printStackTrace();

                  }

              }

      }

      }