1 2 Previous Next 22 Replies Latest reply on Jun 13, 2012 5:50 PM by shadowcreeper Go to original post
      • 15. Re: How to specify host/port in remote JNDI lookup on JBoss 7.1.1.Final?
        jaikiran

        Wolf-Dieter Fink wrote:

         

         

         

        But I took this from a working code example. Is there a difference between the AS7 versions?

        Other thing is that it looks like this is working by accident if you have a valid jboss-ejb-client.properties in the classpath, maybe this force the behaviour also ?!

         

         

        It's not accident It's intentional. So if you have the jboss-ejb-client.properties in the classpath, the EJB client API will know what nodes to connect to (which by the way might even be totally different from what's specified in the PROVIDER_URL of the JNDI context). The reason remote-naming introduced that "jboss.naming.client.ejb.context" was to avoid forcing users to add a jboss-ejb-client.properties in their classpath for setting up nodes for EJB invocations. When that property is present, the remote-naming implementation will internally create a client context and add the connection created  for the PROVIDER_URL, to the EJB client context.

        • 16. Re: How to specify host/port in remote JNDI lookup on JBoss 7.1.1.Final?
          jaikiran

          Those watching this thread, might be interested in reading this https://community.jboss.org/thread/200911

          1 of 1 people found this helpful
          • 17. Re: How to specify host/port in remote JNDI lookup on JBoss 7.1.1.Final?
            shadowcreeper

            That is excellent, thanks. However, I am still running into issues with this approach:

             

            1. Without adding Context.SECURITY_PRINCIPAL and Context.SECURITY_CREDENTIALS I get "Authentication failed". How can we use anonymous security details with this approach? Not a deal breaker as we should be using security, but is it possible?

             

            2. With this approach, I always get "No EJB receiver available for handling..." IllegalStateException whenever I try to use the bean. Any idea why?

            Edit: The bean is annotated @Stateless @Remote(MyRemoteBean.class) and implements MyRemoteBean.

            // stand-alone integration test (not run from within JBoss, and no jboss-ejb-client.properties available in the class path)

            Properties jndiProperties = new Properties();
            jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
            jndiProperties.put(Context.PROVIDER_URL, "remote://localhost:4447");
            jndiProperties.put("jboss.naming.client.ejb.context", true);
            jndiProperties.put(Context.SECURITY_PRINCIPAL, "login");
            jndiProperties.put(Context.SECURITY_CREDENTIALS, "password");
            InitialContext context = new InitialContext( jndiProperties );

            my.bean.MyRemoteBean myRemoteBean;

            try
            {
               myRemoteBean = (MyRemoteBean)context.lookup( "my-ear/my-jar/MyBeanEJB!my.bean.MyRemoteBean" );
            }
            finally
            {
               context.close();
            }

            myRemoteBean.doSomething(); // IllegalStateException gets thrown here

             

            3. Prerequisites say object must be serializable. What does this mean to a remote EJB? The class itself is not distributed in any library, only the interface. Does this apply to our EJBs? Or only to the proxy (which we have no control over)?

            • 18. Re: How to specify host/port in remote JNDI lookup on JBoss 7.1.1.Final?
              mikemil

              As far as #3 goes, I think the Serializable is required of the input parms and any objects returned - since they need to be passed over the network.

              • 19. Re: How to specify host/port in remote JNDI lookup on JBoss 7.1.1.Final?
                wdfink

                1)

                The remoting connection is secured. Find the <subsystem .....remoting> and remove the security-realm if you want.

                2)

                What you mean by this. Are you able to execute any remote method?

                How the server was started? Do you see any server side errors?

                • 20. Re: How to specify host/port in remote JNDI lookup on JBoss 7.1.1.Final?
                  jaikiran

                  Shadow Creeper wrote:

                   

                   

                  1. Without adding Context.SECURITY_PRINCIPAL and Context.SECURITY_CREDENTIALS I get "Authentication failed". How can we use anonymous security details with this approach? Not a deal breaker as we should be using security, but is it possible?

                   

                  Wolf answered that in his reply. In fact even that article I pointed to does mention that AS7.1 is secured by default and can't be accessed without appropriate security credentials being passed from client.

                   

                   

                  Shadow Creeper wrote:

                   

                  2. With this approach, I always get "No EJB receiver available for handling..." IllegalStateException whenever I try to use the bean. Any idea why?

                  Edit: The bean is annotated @Stateless @Remote(MyRemoteBean.class) and implements MyRemoteBean.

                  // stand-alone integration test (not run from within JBoss, and no jboss-ejb-client.properties available in the class path)

                  Properties jndiProperties = new Properties();
                  jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
                  jndiProperties.put(Context.PROVIDER_URL, "remote://localhost:4447");
                  jndiProperties.put("jboss.naming.client.ejb.context", true);
                  jndiProperties.put(Context.SECURITY_PRINCIPAL, "login");
                  jndiProperties.put(Context.SECURITY_CREDENTIALS, "password");
                  InitialContext context = new InitialContext( jndiProperties );

                  my.bean.MyRemoteBean myRemoteBean;

                  try
                  {
                     myRemoteBean = (MyRemoteBean)context.lookup( "my-ear/my-jar/MyBeanEJB!my.bean.MyRemoteBean" );
                  }
                  finally
                  {
                     context.close();
                  }

                  myRemoteBean.doSomething(); // IllegalStateException gets thrown here

                   

                  Without looking at the entire exception stacktrace and the server side logs of what the JNDI names of that bean are, can't really say what's wrong.

                   

                   

                  Shadow Creeper wrote:

                   

                  3. Prerequisites say object must be serializable. What does this mean to a remote EJB? The class itself is not distributed in any library, only the interface. Does this apply to our EJBs? Or only to the proxy (which we have no control over)?

                  That's a statement for all objects that are expected to be available remotely via JNDI (i.e. java:jboss/exported/ namespace). The EJB proxies are implemented and bound by the EJB container and it takes care of having it serializable.

                  • 21. Re: How to specify host/port in remote JNDI lookup on JBoss 7.1.1.Final?
                    shadowcreeper

                    Question 1 was about the fact that when using the jboss-ejb-client.properties file I can set the following to allow me to leave out login details. I don't want to do this in production, but I was just wondering if this was possible using the PROVIDER_URL method.

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

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

                     

                    I found the issue with the IllegalStateException.

                     

                    Here is the context setup:

                    // stand-alone integration test (not run from within JBoss, and no jboss-ejb-client.properties available in the class path)

                    Properties jndiProperties = new Properties();
                    jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
                    jndiProperties.put(Context.PROVIDER_URL, "remote://localhost:4447");
                    jndiProperties.put("jboss.naming.client.ejb.context", true);
                    jndiProperties.put(Context.SECURITY_PRINCIPAL, "login");
                    jndiProperties.put(Context.SECURITY_CREDENTIALS, "password");
                    InitialContext context = new InitialContext( jndiProperties );

                     

                    This works:

                    // stand-alone integration test (not run from within JBoss, and no jboss-ejb-client.properties available in the class path)

                    try
                    {
                       MyRemoteBean myRemoteBean = (MyRemoteBean)context.lookup( "my-ear/my-jar/MyBeanEJB!my.bean.MyRemoteBean" );

                       myRemoteBean.doSomething();
                    }
                    finally
                    {
                       context.close();
                    }

                     

                    This does not:

                    // stand-alone integration test (not run from within JBoss, and no jboss-ejb-client.properties available in the class path)

                    MyRemoteBean myRemoteBean;

                    try
                    {
                       myRemoteBean = (MyRemoteBean)context.lookup( "my-ear/my-jar/MyBeanEJB!my.bean.MyRemoteBean" );
                    }
                    finally
                    {
                       context.close();
                    }

                    myRemoteBean.doSomething(); // IllegalStateException gets thrown here

                     

                    Previously (in JBoss5, and also in JBoss 7.1 when using the jboss-ejb-client.properties method) I would always close the Context after bean lookup (in the finally block as you can see above). Apparently, using the PROVIDER_URL, this causes the bean to disconnect.

                     

                    Is this a bug? Or is this expected?

                     

                    EDIT: This is really 2 separate new questions (the original question has been answered), moving this to another discussion. Thanks a ton to Wolf and Jaikiran!

                    JBoss 7.1 JNDI lookup using PROVIDER_URL without PRINCIPAL and CREDENTIALS

                    Is InitialContext.close neccessary in JBoss 7.1?

                    • 22. Re: How to specify host/port in remote JNDI lookup on JBoss 7.1.1.Final?
                      shadowcreeper

                      Ah, that makes complete sense, and I already do this.

                      1 2 Previous Next