2 Replies Latest reply on Feb 20, 2008 5:25 AM by marcusdidiusfalco

    Problem with simple clustering example

    marcusdidiusfalco

      Hallo, I try to follow a very simple example for clustering (from Jamae, Johnson: JBoss in Action)

      JBoss 4.2.0.GA
      On a Windows XP machine I have started two instances, node1 and node2 which are copies of the all configuration out of the box. On node2 I use the BindingManager. Both instances start up normally and you can tell from the output that there are two nodes in the DefaultPartion.
      I have deployed a very simple SLSB to both nodes.

      import javax.ejb.Remote;
      
      @Remote
      public interface Counter {
       public void printNumber(int number);
      }
      
      
      @Stateless
      public class CounterBean implements Counter {
      
       public void printNumber(int number) {
       System.out.println(number);
      
       }
      
      }
      
      <jboss>
       <enterprise-beans>
       <session>
       <ejb-name>CounterBean</ejb-name>
       <jndi-name>CounterBean</jndi-name>
       <clustered>True</clustered>
       </session>
       </enterprise-beans>
      </jboss>
      
      


      The deployment succeeds.

      The client:
      public class Testclient {
       public static void main(String[] args) {
       try {
       Context initialContext = new InitialContext();
       Counter counter = (Counter) initialContext.lookup("CounterBean/remote");
       for (int i=0; i<1000; i++) {
       counter.printNumber(i);
       Thread.sleep(500);
       }
       } catch (NamingException e) {
       e.printStackTrace();
       } catch (InterruptedException e) {
       e.printStackTrace();
       }
      
       }
      }


      jndi.properties:

      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces


      When I run the client a get a
      javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]
       at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1317)
       at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1446)
       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 clustering.Testclient.main(Testclient.java:10)
      Caused by: java.net.SocketTimeoutException: Receive timed out
       at java.net.PlainDatagramSocketImpl.receive0(Native Method)
       at java.net.PlainDatagramSocketImpl.receive(PlainDatagramSocketImpl.java:136)
       at java.net.DatagramSocket.receive(DatagramSocket.java:712)
       at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1287)


      I have already tried to disable my firewall and set loopback="true" in <udp .. in cluster-service.xml.

      Many thanks for any advise

        • 1. Re: Problem with simple clustering example
          marcusdidiusfalco

          Ok, I have tried some more variations.
          When I remove the jboss.xml and put the @Clustered annotation on the SLSB and use

          jndi.properties

          java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
          java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
          java.naming.provider.url=localhost:1100


          it works nicely.

          However when I remove the @Clustered annotation and put jboss.xml back into META-INF I get a
          javax.naming.NotContextException
           at org.jnp.server.NamingServer.lookup(NamingServer.java:285)
           at org.jboss.ha.jndi.TreeHead.lookupLocally(TreeHead.java:296)
           at org.jboss.ha.jndi.TreeHead.lookup(TreeHead.java:215)
           at org.jboss.ha.jndi.HAJNDI.lookup(HAJNDI.java:155)
          ...


          So the jboss.xml must be faulty, however my XMLParser validates it and the Bean is definitely bound in the Global JNDI namespace.

          What does that NotContextException mean?

          Or can anybody point out how to use a correct deployment descriptor for clustering. The examples in the clustering guid or the JB336 course do not look differently.

          • 2. Re: Problem with simple clustering example
            marcusdidiusfalco

            The problem was with the

            <jndi>
            Element, when I remove it, the client correctly looks up the Bean and the example works with jboss.xml.