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.
Regards
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.initial","org.jnp.interfaces.NamingContextFactory");
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();
message.setText(sCommand);
queueSender.send(queue, message);
queueSession.close();
queueConnection.close();