1 Reply Latest reply on Sep 27, 2004 6:47 PM by Jeff Hiatt

    Exception: ConnectionFactory not bound

    Eliane Bortolaso Newbie

      Hi.

      I am having problems with run a client for my mbean.
      I am studing the tutorial for building j2ee applications using jboss and eclipse. In the chapter 7 the client of the mbean throws javax.naming.NameNotFoundException: ConnectionFactory not bound.

      What should I do?

      My client code:

      /*
      * Created on 27/09/2004
      */
      package au.com.tusc.mdb;

      import java.util.Hashtable;

      import javax.jms.ObjectMessage;
      import javax.jms.Queue;
      import javax.jms.QueueConnection;
      import javax.jms.QueueConnectionFactory;
      import javax.jms.QueueSender;
      import javax.jms.QueueSession;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;

      /**
      * @author Li
      *
      */
      public class RequestMDBClient
      {
      private InitialContext getContext() throws NamingException
      {
      Hashtable props = new Hashtable();
      props.put(InitialContext.INITIAL_CONTEXT_FACTORY,
      "org.jnp.interfaces.NamingContextFactory");
      props.put(InitialContext.PROVIDER_URL,"jnp://127.0.0.1:1099");

      InitialContext initialContext = new InitialContext(props);
      return initialContext;
      }

      public void testMDBBean()
      {
      RequestItems ri = new RequestItems("RUSTY","PASSWD","14",30);
      try
      {
      System.out.println("Looking up the factory");
      InitialContext ctx = getContext();
      QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
      System.out.println("Looking up the queue");
      Queue queue = (Queue)ctx.lookup("queue/MdbQueue");
      System.out.println("Creating the connection now...");
      QueueConnection connection = factory.createQueueConnection();
      System.out.println("Create the session now...");
      QueueSession session = connection.createQueueSession(true, 1);
      System.out.println("Creating the sender now...");
      QueueSender sender = session.createSender(queue);
      ObjectMessage message = session.createObjectMessage();
      System.out.println("Setting the object in message now...");
      message.setObject(ri);
      System.out.println("Sending the message");
      sender.send(message);
      System.out.println("Shuting down");
      session.commit();
      session.close();
      connection.close();
      System.out.println("Finished");
      }
      catch(Exception e)
      {
      e.printStackTrace();
      }
      }

      public static void main(String[] args)
      {
      RequestMDBClient test = new RequestMDBClient();
      test.testMDBBean();
      }
      }