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: 10.239.20.193:11
      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 10.239.20.193:
      1100 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server 10.239.20.193:1100 [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 10.239.20.193:1100 [Root exception is javax.naming.Ser
      viceUnavailableException: Failed to connect to server 10.239.20.193:1100 [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 10.239.20.193:1100 [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 -->
      ${jboss.partition.name:DefaultPartition}

      <!-- The address used to determine the node name -->
      ${jboss.bind.address}

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

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

      <!-- 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"
      proxy-type="attribute">jboss:service=${jboss.partition.name:DefaultPartition}
      <!-- Bind address of bootstrap and HA-JNDI RMI endpoints -->
      ${jboss.bind.address}
      <!-- Port on which the HA-JNDI stub is made available -->
      1100
      <!-- RmiPort to be used by the HA-JNDI service once bound. 0 => auto. -->
      1101
      <!-- Accept backlog of the bootstrap socket -->
      50
      <!-- The thread pool service used to control the bootstrap and
      auto discovery lookups -->
      <depends optional-attribute-name="LookupPool"
      proxy-type="attribute">jboss.system:service=ThreadPool

      <!-- A flag to disable the auto discovery via multicast -->
      false
      <!-- Set the auto-discovery bootstrap multicast bind address. If not
      specified and a BindAddress is specified, the BindAddress will be used. -->
      ${jboss.bind.address}
      <!-- Multicast Address and group port used for auto-discovery -->
      ${jboss.partition.udpGroup:230.0.0.4}
      1102
      <!-- The TTL (time-to-live) for autodiscovery IP multicast packets -->
      16
      <!-- The load balancing policy for HA-JNDI -->
      org.jboss.ha.framework.interfaces.RoundRobin

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


      3. jboss.xml changes:

      <ejb-name>Calculator</ejb-name>
      <jndi-name>Calculator</jndi-name>
      True
      <cluster-config>
      <partition-name>DefaultPartition</partition-name>
      <home-load-balance-policy>
      org.jboss.ha.framework.interfaces.RoundRobin
      </home-load-balance-policy>
      <bean-load-balance-policy>
      org.jboss.ha.framework.interfaces.RoundRobin
      </bean-load-balance-policy>
      </cluster-config>

      <configuration-name>
      Standard Stateless SessionBean
      </configuration-name>
      <resource-ref>
      <res-ref-name>jdbc/PPM</res-ref-name>
      <jndi-name>java:/EntityMedia</jndi-name>
      </resource-ref>
      <method-attributes>

      <method-name>*</method-name>
      <transaction-timeout>3600</transaction-timeout>

      </method-attributes>

        • 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();
          t.go();
          }

          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://10.239.20.193:1100");
          p.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
          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.