2 Replies Latest reply on Jan 1, 2005 9:20 AM by Chris Malan

    Cannot send a message to a queue

    Chris Malan Novice

      First of all, this works on my machine at home. The problem is with the same web-app deployed at alacrtejava. The exception is:

      03:03:40,106 WARN [NamingContext] Failed to connect to localhost:1099
      javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused]

      This is the relevant code in my app:

      Properties properties = new Properties();
      properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      properties.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
      properties.put(Context.PROVIDER_URL, "localhost"); &&&&&&&&&&&&&
      InitialContext context = new InitialContext(properties);
      QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory)context.lookup("UILConnectionFactory");
      **********
      queueConnection = queueConnectionFactory.createQueueConnection();
      QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
      Queue queue = (Queue)context.lookup("queue/AdQueue");


      The exception gets thrown in the line above the asterisks (****), but I suspect the root of the problem may be in the line with the ampersands (&&&).

      This is alacartejava's terse and cryptic reply:

      That is because you are running a RMI server at home. That is not the case here. Please follow the JBoss recommended in-process method for JNDI.

      I am running the same JBoss-Jetty they are. My jndi.properties file is stock standard.

      Searching the posts yields one post with very much the same problem, but no replies. The FAQ yields no answers.

      Can anybody please point me to "the JBoss recommended in-process method for JNDI." Any other solution will also be fine.

      Thanks,

      Chris

        • 1. Re: Cannot send a message to a queue
          rino salvade Newbie

          The initial context is normaly a RMI reference. So if no RMI server is running, this will fail. To my knowledge if you do not set the provider_URL then the NamingContext uses the VM Naming instance set by the Main MBean.
          Hope this does the trick, I have not tested it.
          Make sure that no jndi.properties file is sitting around.

          • 2. Re: Cannot send a message to a queue
            Chris Malan Novice

             

            "rino_salvade" wrote:
            The initial context is normaly a RMI reference. So if no RMI server is running, this will fail. To my knowledge if you do not set the provider_URL then the NamingContext uses the VM Naming instance set by the Main MBean.
            Hope this does the trick, I have not tested it.
            Make sure that no jndi.properties file is sitting around.


            Hi Rino,

            Thanks. You are absolutely right. I now no longer put the provider_URL in the initial context and use the JVM connectionFactory which does not use socket connections. The whole application runs in the same JVM. Everything now works as it is supposed to. Thanks again.

            Chris