error: ConnectionFactory not bound
843830Mar 11 2005 — edited Dec 7 2006Hi,
I have created a method in session bean to send message. below is the code of my method
public void sendMessage() throws NamingException,JMSException{
QueueConnectionFactory cf;
QueueConnection connection;
QueueSession session;
Queue destination;
QueueSender sender;
TextMessage message;
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL,
"localhost:1099");
Context ctx = new InitialContext(env);
//ctx = new InitialContext();
cf = (QueueConnectionFactory)ctx.lookup("ConnectionFactory");
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 World1!");
System.out.println("Sending Message.");
sender.send(message);
connection.close();
System.out.println("Done.");
}
I am getting the following error in the browser
javax.naming.NameNotFoundException: ConnectionFactory not bound
Can anyone tell me why this error is coming
Thanks