1 Reply Latest reply on Feb 18, 2003 8:33 PM by Justin Permar

    JMS error

    Justin Permar Newbie

      I've attempted to get the code in Sun's JMS tutorial working (chapter 4, http://java.sun.com/products/jms/tutorial/1_3_1-fcs/doc/client.html#1056518)

      I seem to have a simple but very annoying problem. My program stops in the following code:

      /*
      * Create a JNDI API InitialContext object if none exists
      * yet.
      */
      Hashtable env = new Hashtable();
      //env.put("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
      env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      //env.put("java.naming.provider.url","jnp://localhost");
      env.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
      env.put("jnp.socketFactory","org.jnp.interfaces.TimedSocketFactory");
      env.put("jnp.timeout","10000");
      env.put("jnp.notimeout","10000");
      try {
      jndiContext = new InitialContext(env);
      //jndiContext = new InitialContext();
      } catch (NamingException e) {
      System.out.println("Could not create JNDI API " +
      "context: " + e.toString());
      System.exit(1);
      }

      /*
      * Look up connection factory and queue. If either does
      * not exist, exit.
      */

      try {
      System.out.println("trying to get connection factory via JNDI");
      queueConnectionFactory = (QueueConnectionFactory)
      jndiContext.lookup("ConnectionFactory");

      <rest of code deleted since my program stops with this lookup>
      ...

      I give the above environment code for reference. I believe that environment is all I need. I have set up JBoss 3.0.4 on my local computer (Mandrake Linux 9.0). I run my class with the following line:

      java -classpath ../dist/dist.jar:/home/jpermar/jboss-3.0.4/client/jbossmq-client.jar:/home/jpermar/jboss-3.0.4/client/jbossall-client.jar:/home/jpermar/netgame/config/jndi.properties:/home/jpermar/jboss-3.0.4/client/jnet.jar:/home/jpermar/jboss-3.0.4/client/jnp-client.jar:/home/jpermar/jboss-3.0.4/client/log4j.jar com.jpermar.client.communication.jms.SimpleQueueSender queue/A 3

      where dist.jar has my SimpleQueueSender (same code as on the Sun link at the top of this post). I believe queue/A is a default queue created by JBoss upon start (I'm starting JBoss with "default" options, i.e., bin/run.sh).

      I get the following output:

      Queue name is queue/A
      trying to get connection factory via JNDI
      {java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, jnp.timeout=10000, jnp.notimeout=10000, jnp.socketFactory=org.jnp.interfaces.TimedSocketFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      JNDI API lookup failed: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]

      It seems unable to communication with the nameserver. If I try the above program with no timeout, it just hangs indefinitely. I have also tried the same call with Sun's J2EE reference implementation, and get stuck at the same place. I'm assuming this is a simple problem where I'm not pointing at the nameserver, or maybe a firewall problem? I've seen some references to /etc/hosts needing to be correct. My /etc/hosts is simply "127.0.0.1 localhost.localdomain localhost" I get the same error with a software firewall up (Mandrake's firewall) and with it down. Please point me in the right direction, if you can...