2 Replies Latest reply on May 23, 2012 5:13 PM by tdanecito

    How to access EJB in 7.1.1 from remote client...

    tdanecito

      Hi,

       

      I am moving from Jboss 5.1GA to 7.1.1 final and encountered some challenges when trying to access an EJB from a client app running in Tomcat in another jvm.

       

      I noticed that when deploying my jar in a EAR from 5.1GA to 7.1.1 final that it bound the EJB's to only something called java:global/earname/jarname/beanname!classname

       

      When I tried to access the ejb from a war app from Tomcat I get a javax.naming.NameNotFoundException not matter what changes I tried in the client code in the war file.

       

      So I am wondering:

      1. Is the EJB accessable using java:global/... from another jvm?

      2. Can I use ejb:earname/jarname//beanname!classname without makeing any changes to existing EJB somehow?

      3. To make number 2 work do I need to have "exported" the beans somehow?

      4. Does the remote (org.jboss.naming.remote.client.InitialContextFactory) really allow remote access to another EJB in a jvm using Jboss proprietary java:global/...: from another jvm?

       

      The code I am using for service locator to create the context for java:global/... is:

       

        Properties properties = new Properties();
        properties.put(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.naming.remote.client.InitialContextFactory");
        properties.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
        properties.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS", "JBOSS-LOCAL-USER");
        properties.put(Context.PROVIDER_URL, "remote://" + serviceHost + ":4447");
        properties.put(Context.SECURITY_PRINCIPAL,"name");
        properties.put(Context.SECURITY_CREDENTIALS,"password");

       

      If I try to use ejb:earname/...

        Properties properties = new Properties();

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

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

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

        properties.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS", "JBOSS-LOCAL-USER");

        properties.put(Context.PROVIDER_URL, "remote://" + serviceHost + ":4447");

        properties.put(Context.SECURITY_PRINCIPAL,"name");

        properties.put(Context.SECURITY_CREDENTIALS,"password");

       

      Is the above correct?

       

      Thanks,

      -Tony

        • 1. Re: How to access EJB in 7.1.1 from remote client...
          suikast42

          Hi tony,

          remoting in AS 7.1.x is completly rewritten.

           

          1. Is the EJB accessable using java:global/... from another jvm?

          2. Can I use ejb:earname/jarname//beanname!classname without makeing an changes to existing EJB somehow?

          3. To make number 2 work do I need to have "exported" the beans somehow?

          4. Does the remote (org.jboss.naming.remote.client.InitialContextFactory) really allow remote access to another EJB in a jvm using Jboss proprietary java:global/...: from another jvm?


           


          1. No. The JavaEE 6 spec says that this lookup must only available in the container. There's nothing about remote access.

          2. You must use lookups like this:

          For stateless beans: ejb:myapp/myejbjar/MyEjbName!com.test.MyRemoteInterface

          For stateful beans: ejb:myapp/myejbjar/MyStatefulName!comp.test.MyStatefulRemoteInterface?stateful

          3. You need this for jms

          4. ??

           

          If you need an example project you can download the attached project from this thread https://community.jboss.org/message/735877#735877.

          And read the docu https://docs.jboss.org/author/display/AS71/JNDI+Reference

          • 2. Re: How to access EJB in 7.1.1 from remote client...
            tdanecito

            Thanks Everyone I was able to get the ejb: reference to work. Then I had to add the jboss-client.properties into the class path on the client (Tomcat 7.x) else I would not get a "reciever".

            Only took a couple of days to figure it out and much googling to find out.

             

            Regards,

            -Tony