7 Replies Latest reply on Feb 20, 2012 9:44 AM by Joseph Fouts

    Question regarding the EJB invocations from a remote client using JNDI example

    Joseph Fouts Novice

      I tried running a version of the SLSB example from the following:

      https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI

       

      My problem is I have two connections supported in the client's jboss-ejb-client.properties file but yet all of the requests only go to the first connection defined in the remote.connections= definition.

       

      I'm running as-7.1.0.Final

       

      Here is my client's jboss-ejb-client.properties file:

      ------------------------------------

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

       

      remote.connections=default, two

      remote.connection.default.host=10.100.100.12

      remote.connection.default.port = 4447

      remote.connection.default.username=xxxx

      remote.connection.default.password=xxxx

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

       

      remote.connection.two.host=10.100.100.2

      remote.connection.two.port = 4447

      remote.connection.two.username=xxx

      remote.connection.two.password=xxxx

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

       

      ------------------------------------

       

      Started both servers using the standalone.xml

       

      Executed client several times and all client requests go to connection "default".

       

      If I change the jboss-ejb-client.properties to:

           remote.connections=two, default

       

      Then all client requests go to connection two.

       

      Here is my code for the lookup and invocation of the SLSB from the client:

       

                 final Hashtable<String,String> jndiProperties = new Hashtable<String, String>();

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

                 final Context context = new InitialContext(jndiProperties);

                 final String appName = "";

                 final String moduleName = "LIDP-ADMI2";

                 final String distinctName = "";

                 final String beanName = "CalculatorBean";

                 final String viewClassName = RemoteCalculator.class.getName();

                 String bean = "ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName;

                         

                  final RemoteCalculator statelessRemoteCalculator = (RemoteCalculator) context.lookup(bean);   

                  ....

                  ....

               

                  int sum = statelessRemoteCalculator.add(a, b);

                

                  int difference = statelessRemoteCalculator.subtract(num1, num2);

            

       

      The client requests should be going to both connections correct?

      If yes is there something that I am not setting up correctly?

       

      Thanks.

        • 1. Re: Question regarding the EJB invocations from a remote client using JNDI example
          Joseph Fouts Novice

          Client console is also posting the following warning message:

           

          07:16:38,152 Remoting "client-endpoint" task-4 WARN  - Unsupported message received with header 0xffffffff [org.jboss.ejb.client.remoting.ChannelAssociation]

           

          I added the following to the jboss-ejb-client.properties file but recieved the same results:

           

          endpoint.name=client-endpoint

          • 2. Re: Question regarding the EJB invocations from a remote client using JNDI example
            Joseph Fouts Novice

            Some additonal information:

             

            If the jboss-ejb-cient.properties is defined with the following:

               remote.connections=two, default

             

            And connection "two" does not start the server I get the following exception:

             

            07:24:46,392 main WARN  - Could not register a EJB receiver for connection to remote://10.100.100.2:4447 [org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector]

            java.lang.RuntimeException: Operation failed with status WAITING

                at org.jboss.ejb.client.remoting.IoFutureHelper.get(IoFutureHelper.java:93)

                at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.setupEJBReceivers(ConfigBasedEJBClientContextSelector.java:115)

                at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.<init>(ConfigBasedEJBClientContextSelector.java:77)

                at org.jboss.ejb.client.EJBClientContext.<clinit>(EJBClientContext.java:76)

                at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:120)

                at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)

                at $Proxy0.add(Unknown Source)

                at com.lidp.main.ClientProcess01.<init>(ClientProcess01.java:52)

                at com.lidp.main.ClientProcess01.main(ClientProcess01.java:28)

            07:24:46,530 Remoting "config-based-ejb-client-endpoint" task-2 WARN  - Unsupported message received with header 0xffffffff [org.jboss.ejb.client.remoting.ChannelAssociation]

            07:24:47,049 main DEBUG - Remote calculator returned sum = 544 [com.lidp.main.ClientProcess01]

             

             

            So does this indicate that it will only go to the second connection if the first connection fails?

            Trying to get hit the connections in a round robin kind of load balance.

             

            Any suggestions?

             

            Thanks.

            • 3. Re: Question regarding the EJB invocations from a remote client using JNDI example
              Joseph Fouts Novice

              I still can't get this test case to to work.

               

              Does anyone have any idea what might be going wrong?

               

              Thanks.

              • 4. Re: Question regarding the EJB invocations from a remote client using JNDI example
                Prasad Deshpande Expert
                If the jboss-ejb-cient.properties is defined with the following:

                   remote.connections=two, default

                AFAIK, that mean your EJB receiver is pointing to these two places. What is eventually does is, it creates connection to both receivers & then whenever you call any method on ejb, it will go & actually find which one is "serving" that ejb. & will cache that information for future use. Here I think what could be happening is since you put server down "two", it is not able to create connection/receiver for "two" & hence throwing an exception.

                 

                Think of it as places where you can get all your ejb's servered from and not as order of receivers where ejb's will servered from.

                • 5. Re: Question regarding the EJB invocations from a remote client using JNDI example
                  Joseph Fouts Novice

                  So what you are saying is that I cannot load balance to each of the conncections defined?

                  Then this type of defiition would only be for fail safe purposes that that if the first connection failed the second connection would get the request?

                   

                  Thanks for you help.

                  • 6. Re: Question regarding the EJB invocations from a remote client using JNDI example
                    jaikiran pai Master

                    Joseph Fouts wrote:

                     

                     

                    So does this indicate that it will only go to the second connection if the first connection fails?

                    Yes. That's correct.

                     

                    Note that the there isn't currently is configurable way to decide which node a request goes if multiple nodes can serve the same deployment, like in your case. I'll add something around this, this week. Note that this has nothing to do with clustering. You can have 2 non-clustered instances where the same deployment might be deployed.

                    • 7. Re: Question regarding the EJB invocations from a remote client using JNDI example
                      Joseph Fouts Novice

                      Great thanks for the clarification.

                       

                      Jaikiran my real goal is to get clustering to work with calling SLSB from another SLSB.  I want this call to go to each one of the

                      clustered in a round robin fashion.  Can you please tell me if I can do this with 7.1.0.Final.  And if yes I do I setup the lookup and

                      invocation for this type of call.  In JBoss 5.1 I had to do the following:

                       

                      Properties p = new Properties();  

                               p.put(Context.INITIAL_CONTEXT_FACTORY,  

                                       "org.jnp.interfaces.NamingContextFactory");

                               p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");

                              

                               String partitionName = System.getProperty("jboss.partition.name", "clusterPartition2");

                               p.put("jnp.partitionName", partitionName);         

                                    

                               try

                               {

                                  ctx = new InitialContext(p);

                               }

                       

                       

                      clientPartition2 was setup as the cluster that I had setup with 4 servers from our network and everything worked fine. 

                      With the above code I was able to get the calls to the envocation to my SLSB to

                      occur with the round robin load balance.  Meaning a call to server 1... server 2... server 3 .... server 4 ...

                       

                      Any help is appreciated.

                       

                      Thanks.