2 Replies Latest reply on Jun 19, 2004 11:32 AM by Stephane Nicoll

    Null ConnectionFactory

    pfonseca Newbie

      Hello all,

      I have a small problem in my first JMS client program. I have installed a fresh and clean JBoss 3.2.4 server, and without any further configuration, tried a little program, that is posted next.

      Can anybody please tell me why do i always get a null reference on context.lookup("ConnectionFactory") instruction ?

      I notice that ConnectionFactory appears on the JNDI object list of the Jmx Console.

      Pedro F.

      QueueConnectionFactory queueFactory = null;
      QueueConnection queueConnection = null;
      QueueSession queueSession = null;
      QueueSender queueSender = null;
      Queue queue = null;
      Context context = null;
      Hashtable prop = new Hashtable();
      boolean bReply = false;
      Object factory = null;

      String sCommand = "Hello MSG!!";

      prop.put("java.naming.factory.url", "localhost:1099");
      prop.put("javax.naming.rmi.security.manager", "no");
      prop.put(Context.URL_PKG_PREFIXES, "org.jboss.naming");
      prop.put(Context.PROVIDER_URL, "localhost:1099");
      context = new InitialContext(prop);

      factory = context.lookup("ConnectionFactory");
      if (factory == null) {
      throw new Exception("ConnectionFactory is null ...");

      queue = (Queue)context.lookup("queue/A");
      if (queue == null) {
      throw new Exception("queue/A is null ...");

      queueFactory = (QueueConnectionFactory)factory;
      queueConnection = queueFactory.createQueueConnection();
      queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

      queueSender = queueSession.createSender(queue);

      TextMessage message = queueSession.createTextMessage();
      queueSender.send(queue, message);