3 Replies Latest reply on Jun 1, 2007 2:33 AM by shri ram

    JBoss clustering - ejb lookup using HA-JNDI problem

    shri ram Newbie

      I am getting the following exception when I try to invoke a clustered EJB from a remote java client.
      The same program works when I invoke through the port 1099, but not through 1100..

      Please let me know where the problem is.

      1. Exception trace::
      Exception in thread "main" javax.naming.CommunicationException: Could not obtain connection to any of these urls:
      00 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeo
      utException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server
      1100 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server [Root exception i
      s java.net.ConnectException: Connection refused: connect]]]
      at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1414)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:594)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at CalculatorClient.go(CalculatorClient.java:17)
      at CalculatorClient.main(CalculatorClient.java:11)
      Caused by: javax.naming.CommunicationException: Failed to connect to server [Root exception is javax.naming.Ser
      viceUnavailableException: Failed to connect to server [Root exception is java.net.ConnectException: Connection
      refused: connect]]
      at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:269)
      at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1385)
      ... 5 more
      Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server [Root exception is java.net.Co
      nnectException: Connection refused: connect]
      at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:243)
      ... 6 more
      Caused by: java.net.ConnectException: Connection refused: connect
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
      at java.net.Socket.connect(Socket.java:516)
      at java.net.Socket.connect(Socket.java:466)
      at java.net.Socket.(Socket.java:366)
      at java.net.Socket.(Socket.java:266)
      at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:84)
      at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:77)
      at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:239)
      ... 6 more

      2. Setting changes I had done.:

      cluster-service.xml (I havent made any changes in cluster-service.xml and its present with the default values)

      <!-- Name of the partition being built -->

      <!-- The address used to determine the node name -->

      <!-- Determine if deadlock detection is enabled -->

      <!-- Max time (in ms) to wait for state transfer to complete. Increase for large states -->

      <!-- The JGroups protocol configuration -->

      HA JNDI entries:

      <!-- We now inject the partition into the HAJNDI service instead
      of requiring that the partition name be passed -->
      <depends optional-attribute-name="ClusterPartition"
      <!-- Bind address of bootstrap and HA-JNDI RMI endpoints -->
      <!-- Port on which the HA-JNDI stub is made available -->
      <!-- RmiPort to be used by the HA-JNDI service once bound. 0 => auto. -->
      <!-- Accept backlog of the bootstrap socket -->
      <!-- The thread pool service used to control the bootstrap and
      auto discovery lookups -->
      <depends optional-attribute-name="LookupPool"

      <!-- A flag to disable the auto discovery via multicast -->
      <!-- Set the auto-discovery bootstrap multicast bind address. If not
      specified and a BindAddress is specified, the BindAddress will be used. -->
      <!-- Multicast Address and group port used for auto-discovery -->
      <!-- The TTL (time-to-live) for autodiscovery IP multicast packets -->
      <!-- The load balancing policy for HA-JNDI -->

      <!-- Client socket factory to be used for client-server
      RMI invocations during JNDI queries
      <!-- Server socket factory to be used for client-server
      RMI invocations during JNDI queries

      3. jboss.xml changes:


      Standard Stateless SessionBean



        • 1. Re: JBoss clustering - ejb lookup using HA-JNDI problem
          shri ram Newbie

          Here is the client program for the same..

          import javax.naming.Context;
          import javax.naming.*;
          import javax.rmi.*;
          import java.util.*;

          import com.arbitron.ppm.ops.sampling.*;

          class CalculatorClient {
          public static void main(String args[]) throws Exception {
          CalculatorClient t = new CalculatorClient();

          public void go() throws Exception {
          Context ctx = getContextExternalClient();

          CalculatorHome calculatorHome = (CalculatorHome) PortableRemoteObject.narrow(ctx.lookup("Calculator"), CalculatorHome.class);
          Calculator calculator = calculatorHome.create();
          String answer = calculator.add(234, 555);
          System.out.println("answer : "+ answer);


          private Context getContextExternalClient() throws Exception {
          Properties p = new Properties();
          p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
          p.put(Context.PROVIDER_URL, "jnp://");
          Context ctx = new InitialContext(p);
          return ctx;


          • 2. Re: JBoss clustering - ejb lookup using HA-JNDI problem
            Brian Stansberry Master

            What address are you passing to -b when you start JBoss?

            • 3. Re: JBoss clustering - ejb lookup using HA-JNDI problem
              shri ram Newbie

              Previously, I was not starting the server with run -c all.
              Now it works fine.

              Thanks for your help.