aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes P2P using WSAD's embedded JMS- Naming Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "P2P using WSAD Watch "P2P using WSAD New topic
Author

P2P using WSAD's embedded JMS- Naming Exception

Sam Gehouse
Ranch Hand

Joined: Jul 21, 2003
Posts: 281
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();
//TODO: NEED TO POPULATE context

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);
queueConnection.start();
while (true) {
Message m = queueReceiver.receive(1);
if (m != null) {
if (m instanceof TextMessage) {
message = (TextMessage) m;
System.out.println("Reading message: " +
message.getText());
} else {
break;
}
}
}
} catch (JMSException e) {
System.out.println("Exception occurred: " +
e.toString());
} finally {
if (queueConnection != null) {
try {
queueConnection.close();
} 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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: P2P using WSAD's embedded JMS- Naming Exception