2 Replies Latest reply on Apr 17, 2006 4:36 PM by Shriram Rajagopal

    ConnectionFactory not bound error

    Shriram Rajagopal Newbie

      1) I have been trying to use a standalone JMS sender.

      import javax.jms.*;
      import javax.naming.*;

      public class MessageToQueue
      public static void main(String[] args)
      throws NamingException,JMSException
      InitialContext ctx;
      QueueConnectionFactory cf;
      QueueConnection connection;
      QueueSession session;
      Queue destination;
      QueueSender sender;
      TextMessage message;
      ctx = new InitialContext();
      cf = (QueueConnectionFactory)ctx.lookup("java:/QueueConnectionFactory");
      destination = (Queue)ctx.lookup("queue/testQueue");
      connection = cf.createQueueConnection();
      session = connection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
      sender = session.createSender(destination);
      message = session.createTextMessage();
      message.setText("Hello World!");

      System.out.println("Sending Message.");



      2) I have the following in the JNDI properties in C:\jboss-4.0.3SP1\server\default\conf:


      3) I have the following in the jboss-service.xml in

      <!-- The listening port for the bootstrap JNP service. Set this to -1
      to run the NamingService without the JNP invoker listening port.

      4) JBOSS server is on port 8080. Started the server

      5) Executed this in command "java MessageSender"
      Got this error:
      Exception in thread "main" javax.naming.NameNotFoundException: QueueConnectionFactory not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:514)
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:522)
      at org.jnp.server.NamingServer.getObject(NamingServer.java:528)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:281)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
      at java.naming.InitialContext.lookup(InitialContext.java:351)
      at MessageToQueue.main(MessageToQueue.java:17)

      Could you let me know what is the exact problem? Thanks


        • 1. Re: ConnectionFactory not bound error
          Frank Langelage Master

          I don't have an JBoss system available at the moment, but
          JNDi-names with prefix "java:/" are normally used if you have an resource-ref in your ejb-jar.xml. Take a look at jmx-console -> JNDI view to see what's available.
          We simply use "QueueConnectionFactory" as JNDI name in our code.

          • 2. Re: ConnectionFactory not bound error
            Shriram Rajagopal Newbie

            Thanks. I got the problem solved. I had to set up hsqldb jbdc service to make it work. I went through the JMS concepts on the JBOSS site, but could find anywhere the concept of having hsql or any other database for running JMS (MDB) etc. I then gathered from the hsqldb-jdbc3-service.xml that it is trying to create a database/table.

            Are the messages in the queues actually persisted in a database? I do understand the need of persistance of the transactions and subsequently a need for a database, but am not sure since this is not mentioned in any of the JMS conceptual articles. Am I missing the point here?