1 Reply Latest reply on Aug 30, 2012 9:21 AM by thomas2008ch

    Problem with JNDI remote lookup

    thomas2008ch

      Hi,

       

      Formerly as I use the Jboss AS 5 and AS 6 I have no problem to run following program which uses the HA 1100  for JNDI lookup. Now in Jboss AS 7 this is not supported. I've tried to change the code accrording to some examples from internet but not succeede.

       

      Here are my codes used in Jboss AS 5 and 6.

       

      [code]

       

      import javax.ejb.Remote;

       

      @Remote

      public interface Counter {

            public void printCount(int messageNumber);

      }

       

      [/code]

       

       

      [code]

      import javax.ejb.Stateless;

      import org.jboss.annotation.ejb.Clustered;

      @Stateless

      @Clustered

      public class CounterBean implements Counter {

            public String printCount(int countNumber) {

                  System.out.println("Request from Client " + countNumber);

                  String rt = new Integer(countNumber).toString();

                  return "Response from server " + rt;

            }

      }

       

      [/code]

       

      [code]

      import javax.naming.Context;

      import javax.naming.InitialContext;

       

      public class ClientCluster {

            public static void main(String[] args) throws Exception {

                  Properties properties = new Properties();

                  properties.put("java.naming.factory.initial",

                              "org.jnp.interfaces.NamingContextFactory");

                  properties.put("java.naming.factory.url.pkgs",

                              "org.jboss.naming:org.jnp.interfaces");

                  properties.put("java.naming.provider.url", "132.13.23.123:1100");

                  InitialContext ctx = new InitialContext(properties);

                  Counter s = (Counter) ctx.lookup("CounterBean/remote");

                  System.out.println("The result can be seen in JBoss AS Console");

                  for (int i = 0; i < 100; i++) {

                        System.out.println(s.printCount(i));

                        Thread.sleep(500);

                  }

            }

      }

       

      [/code]