3 Replies Latest reply on May 28, 2013 1:23 PM by Wolf-Dieter Fink

    Jboss EAP 6.0.0 : Remote EJB proxy cache for Swing client

    ganesh jadhav Newbie

      Hi,

       

      We have an application deployed on Jboss EAP 6.0.0 on Linux. Application contains a SLSB. At client we have a swing based application. While the client starts, it gets the data from DB using the SLSB. Remote lookup is successful and i can call the remote EJB. Initially at client side we use to cache the looked up remotehome ( EJBHome)interfaces to avoid the lookups. Now with Jboss EAP 6.0.0 (jboss 7 +AS) this is changed and we are getting ejb proxies.

       

      We tried to cache these proxies, just like we did for remotehome, but sometimes we get the following exception with the cached proxies. 

      java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling.

       

       

      We are using application without this cache (and repetative lookups). I have not changed any configuration on server for ejb. Question is why we are not able to cache the proxies? How to see if the proxy is stale, and if it is stale then do lookup. Client code : We want to cache and resuse the object returned from this method (it return EJBObject ) 

       

      private Object lookupRemoteHome(String jndiHomeName, boolean bRetry)
      {
        try
        {
         Properties env = new Properties();
         env.put(INITIAL_FACTORY, contextFactoryName);
         env.put(PROVIDER_URL, hostURI);
         env.put(PRINCIPAL, user);
         env.put(CREDENTIALS, password);

         PropertyBag<String> bag = getPropertyBag();
         if (bag != null && bag.size() > 0)
         {
          ListOrderedMap<String, String> propMap = bag.getProperties();
          for (String key : propMap.keyList())
          {
           env.put(key, propMap.get(key));
          }
         }
        
         env.put("jboss.naming.client.ejb.context", true);
         env.put(javax.naming.Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
        
         InitialContext ctx = new InitialContext(env);
         return ctx.lookup(jndiHomeName);
        }
        catch (NamingException ne)
        {
         if (bRetry)
         {
          return lookupRemoteHome(jndiHomeName, false);
         }
         else
         {
          throw CommonExceptionFactory.createException(CommonExceptionEnum.Names.JNDILookupError, jndiHomeName, ne.getMessage(), ne);
         }
        }
      }

       

      2) jboss-ejb-client.properties

       

      remote.connections=default

      endpoint.name=client-endpoint

      remote.connection.default.port = 4447

      remote.connection.default.host=1.2.3.4

      remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false

      remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false

      jboss.naming.client.ejb.context=true

       

       

      Regards Ganesh

        • 1. Re: Jboss EAP 6.0.0 : Remote EJB proxy cache for Swing client
          jaikiran pai Master

          It looks like you are using remote-naming and not EJB client URL naming (see this for the difference  https://docs.jboss.org/author/display/AS71/Remote+EJB+invocations+via+JNDI+-+EJB+client+API+or+remote-naming+project). remote-naming had a bug https://issues.jboss.org/browse/JBEAP-4 which is fixed in EAP 6.1 (which has been released some days back).

          • 2. Re: Jboss EAP 6.0.0 : Remote EJB proxy cache for Swing client
            ganesh jadhav Newbie

            Hi,

            Thank you for the reply,

            I followed the link, and tried to use EJB client URL way.

             

            My lookup and calling code :

             

            i)  Properties jndiProps = new Properties();
              jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
               jndiProps.put(Context.PROVIDER_URL,"remote://12.16.16.71:4447");
               jndiProps.put(Context.SECURITY_PRINCIPAL, "xyz");
               jndiProps.put(Context.SECURITY_CREDENTIALS, "xyz123");
               jndiProps.put("jboss.naming.client.ejb.context", true);
               jndiProps.put(javax.naming.Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
               InitialContext ctx = new InitialContext(jndiProps);
               final String appName = "com.xyz.firm.bofapp";
                     final String moduleName = "com.xyz.firm.system.esb.gateway.ejb";
                     final String distinctName = "";
                     final String beanName = InboundHandlerBean.class.getSimpleName();
                     final String viewClassName = InboundHandler.class.getName();
                     InboundHandler r= (InboundHandler) ctx.lookup("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName);
               System.out.println(r);
                   r.processMessage("abc");

             

            ii) properties in classpath

             

            remote.connections=default
            endpoint.name=client-endpoint
            remote.connection.default.port = 4447
            remote.connection.default.host= 17.16.16.71
            remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
            remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false

             

            Now i am able to do lookup, but my last call on the looked up proxy fails with

             

            Using above test program the output is

             

             

             

             

            java.lang.IllegalStateException

             

             

            : EJBCLIENT000025: No EJB receiver available for handling [appName:com.xyz.firm.bofapp, moduleName:com.mastek.xyz.firm.esb.gateway.ejb, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@166afb3

             

            I tried to put the test program code in my application swing client, there i got following error

             

            No such EJB[appname=com.xyz.firm.bofapp,modulename=com.mastek.xyz.firm.esb.gateway.ejb,distinctname=,beanname=InboundHandlerBean]

             

             

            Please help me to use this EJB client URL way.

             

             

            Regards

            Ganesh

             

             

             

             

             

            • 3. Re: Jboss EAP 6.0.0 : Remote EJB proxy cache for Swing client
              Wolf-Dieter Fink Master

              You mix the remote-naming and the ejb-client approach.

               

              If you use i) in your post you need to drop the ejb: prefix in your lookup.

              If you will use the jboss-ejb-client.properties in the classpath, you have to add remote.conneciton.default.user=xyz remote.connection.default.password=xyz123

              and use ONLY this property to create the InitialContext Context.URL_PKG_PREFIXES "org.jboss.ejb.client.naming".

              See the document link from Jaikiran's post at the end of the page.

               

              It is not recommened to use a mix of both approaches, the results might unexpected.