File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Websphere 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
JavaRanch » Java Forums » Products » Websphere
Bookmark "P2P using WSAD Watch "P2P using WSAD New topic

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();

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?
I agree. Here's the link:
subject: P2P using WSAD's embedded JMS- Naming Exception
It's not a secret anymore!