I have two instances of JBOSS 4.0.2 Application Server - each running on different machines.
I configured a Queue with a JNDI name queue/SampleQueue in "Machine A"
and started the "Machine A" giving the --host=
I deployed a servlet on JBOSS running in Machine B. This servlet looked-up the Queue deployed on "Machine A" . It failed with exception
javax.jms.InvalidDestinationException: The destination QUEUE.SampleQueue does not exist
However when the same code was run as a stand-alone java program, it worked.
Is this a bug in 4.0.2 or is my configuration wrong?
Please help.
The Servlet Code:
public void writeToJMS() {
try {
java.util.Properties jp = new java.util.Properties();
jp.put(Context.PROVIDER_URL, "jnp://10.250.11.26:1099");
jp.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
Context context = new javax.naming.InitialContext(jp);
QueueConnectionFactory qcf =
(QueueConnectionFactory) context.lookup("java:/XAConnectionFactory");
Queue ioQueue = (Queue) context.lookup("queue/SampleQueue");
QueueConnection qc = qcf.createQueueConnection();
QueueSession qs =
qc.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
QueueSender queueSender = qs.createSender(ioQueue);
System.out.println("Got the queue 1");
TextMessage outMessage = qs.createTextMessage();
System.out.println("Adding Text");
outMessage.setText("hello");
// Ask the QueueSender to send the message we have created
System.out.println(
"Sending the message to " + ioQueue.getQueueName());
System.out.println(ioQueue.toString());
queueSender.send(outMessage);
System.out.println(
"Sent ....... " );
} catch (Exception ex) {
ex.printStackTrace();
}
}