Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Stand alone client for MDB

0 views
Skip to first unread message

Girish Chafle

unread,
Sep 3, 2003, 6:13:42 AM9/3/03
to
Hi,

I am trying to get the following stand-alone jms client (code shown
below) running but am unable to do so and get the following exception.

Msg To Send girish
javax.naming.NameNotFoundException: jms/MyMDBConnectionFactory
at
com.ibm.ejs.ns.jndi.CNContextImpl.doLookup(CNContextImpl.java:1435)
at
com.ibm.ejs.ns.jndi.CNContextImpl.lookup(CNContextImpl.java:1115)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at TestClient.main(TestClient.java:39)

I have used Websphere pluggable application client for Windows and I am
trying to connect to WAS5(on linux) from this client. I have followed
the instructions in installing and using the pluggable application
client
(http://www7b.software.ibm.com/wsdd/downloads/pluggableclient.html). I
have checked at the WAS server and the connection factory and the quue
exist and a servlet running on the same WAS installation is able to find
it. Any clues on what might be going wrong here ?

Also I am not able to get the pluggable application client for websphere
on Linux. Do you know where to find it ? I need it since I have to run
the client on linux for my project work.

import javax.jms.*;
import javax.naming.*;
import java.util.*;

/**
* @author Girish Chafle
*
* To change this generated comment edit the template variable
"typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
public class TestClient {

public static void main(String[] args) {
//set the system properties needed by WAS client runtime
java.util.Properties sp = System.getProperties();
sp.put("org.omg.CORBA.ORBClass","com.ibm.rmi.iiop.ORB");

sp.put("org.omg.CORBA.ORBSingletonClass","com.ibm.rmi.corba.ORBSingleton");


sp.put("javax.rmi.CORBA.UtilClass","com.ibm.rmi.javax.rmi.CORBA.Util");

sp.put("javax.rmi.CORBA.StubClass","com.ibm.rmi.javax.rmi.CORBA.StubDelegateImpl");


sp.put("javax.rmi.CORBA.PortableRemoteObjectClass","com.ibm.rmi.javax.rmi.PortableRemoteObject");


sp.put("java.naming.factory.initial","com.ibm.websphere.naming.WsnInitialContextFactory");

sp.put("java.naming.factory.url.pkgs","com.ibm.ws.naming");
System.setProperties(sp);

try{
String messageToSend = args[0];
if(messageToSend == null)
{
messageToSend = "Default Message";
}
System.out.println("Msg To Send " + messageToSend);
Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
jndiProperties.put(Context.PROVIDER_URL,"iiop://9.182.217.42:2809");
InitialContext jndiContext = new InitialContext(jndiProperties);
QueueConnectionFactory qcf =(QueueConnectionFactory)
jndiContext.lookup("jms/MyMDBConnectionFactory");
System.out.println(qcf.toString());
System.out.println("Getting Queue");
Queue queue = (Queue)
jndiContext.lookup("jms/MyMDBQueue");
System.out.println("Creating connection");
QueueConnection qConnection = qcf.createQueueConnection();
System.out.println("Creating Session");
QueueSession qSession =
qConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
System.out.println("Creating Sender");
QueueSender sender = qSession.createSender(queue);
System.out.println("Creating Text");
TextMessage message = qSession.createTextMessage();
System.out.println("Appending command Line");
System.out.println("Setting Text");
message.setText(messageToSend);
System.out.println("Sending message");
sender.send(message);
System.out.println("Closing sender");
sender.close();
System.out.println("Closing session");
qSession.close();
System.out.println("Closing connection");
qConnection.close();
System.out.println("Connection closed");
}
catch(NamingException ne)
{
ne.printStackTrace(System.out);
}
catch(JMSException e)
{
e.printStackTrace(System.out);
Exception linked = e.getLinkedException();
linked.printStackTrace(System.out);
}

}
}

Even though I got the code running without any classNotFoundExceptions I
am not sure if a) I have the correct code and b)set up the classpath
properly. Can anyone of you give me instructions on the correct way to
write the code and set up the classpath etc for a stand-alone client on
Linux (WAS5) ?

Thanks and Regards

- Girish

0 new messages