Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

P2P using WSAD's embedded JMS- Naming Exception  RSS feed

Sam Gehouse
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using simple P2P using WSAD5.1.1 Test Server's embedded JMS.

I set up JMS tab of WSAD test server as:
Name JNDI Name
MyFactory jms/MyFactory
MyQueue jms/MyQueue
I checked MQ Simulator for Java Developer radio button.
I restarted Server.

My P2P program is:

public class SimpleQueueReceiver {

* Main method.
* @param args the queue used by the example
public static void main(String[] args) throws NamingException {
String queueName = "jms/MyQueue";
Context jndiContext = null;
QueueConnectionFactory queueConnectionFactory = null;
QueueConnection queueConnection = null;
QueueSession queueSession = null;
Queue queue = null;
QueueReceiver queueReceiver = null;
TextMessage message = null;

jndiContext = new InitialContext();

queueConnectionFactory = (QueueConnectionFactory)jndiContext.lookup("jms/MyFactory");
queue = (Queue) jndiContext.lookup(queueName);

try {
queueConnection = queueConnectionFactory.createQueueConnection();
queueSession = queueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
queueReceiver = queueSession.createReceiver(queue);
while (true) {
Message m = queueReceiver.receive(1);
if (m != null) {
if (m instanceof TextMessage) {
message = (TextMessage) m;
System.out.println("Reading message: " +
} else {
} catch (JMSException e) {
System.out.println("Exception occurred: " +
} finally {
if (queueConnection != null) {
try {
} catch (JMSException e) {}

I throws naming exception when trying to find factory. Am I missing anything else? Do I also have to have any MQ jar in classpath?
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!