Author |
Message
|
venkat.rajm |
Posted: Thu Jan 26, 2006 6:40 am Post subject: problem connecting MQSever using client JMS |
|
|
Newbie
Joined: 04 Dec 2005 Posts: 7
|
Hi All,
I am new to the Websphere MQ , i am using Wesphere MQ Client .when i am using core java classes i am getting messages with out any exception . when i am using JMS i am getting some error , any one can help me to over this problem. here i am using point-to-point connection.
operating environment is:
Windows XP
websphere application server 5.1
websphere MQServer 6.0
wesphere MQClient 6.0
In websphere Application server, i have setted Additional Properties for WebSphere MQ Queue Connection Factories and WebSphere MQ Queue Destinations
Here my code :
import java.util.*;
import javax.jms.*;
import javax.jms.Queue;
import javax.naming.directory.*;
import javax.naming.*;
public class PtpReceiver1 {
public static void main(String[] args) {
String queueName = "TRITEKL;
String qcfName = "TRITEKCF" ;--WebSphere MQ Queue Connection Factories ----here i am not sure which ine i have to provide.
Context jndiContext = null;
QueueConnectionFactory queueConnectionFactory= null;
QueueConnection queueConnection = null;
QueueSession queueSession = null;
Queue queue = null;
QueueReceiver queueReceiver = null;
TextMessage message = null;
String providerUrl = "iiop://IMCTRITEK:1414/TRITEKQMGR" ;
String initialContextFactory = "com.ibm.websphere.naming.WsnInitialContextFactory";
try{
Hashtable env = new Hashtable() ;
env.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory) ;
env.put(Context.PROVIDER_URL , providerUrl );
jndiContext = new InitialDirContext(env);
queueConnectionFactory = (QueueConnectionFactory)jndiContext.lookup(qcfName);
queue = (Queue)jndiContext.lookup(queueName);
queueConnection = queueConnectionFactory.createQueueConnection();
queueConnection.start();
queueSession = queueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
queueReceiver = queueSession.createReceiver(queue);
boolean eom = true;
while (eom) {
Message m = queueReceiver.receive(1);
if (m != null) {
if (m instanceof TextMessage) {
message = (TextMessage) m;
System.out.println("Reading message: " +message.getText()); }
else {
break;
}
}
else eom = false;
}
queueConnection.close();
}
catch(Exception e){
e.printStackTrace();
}
}
}
Here my Exception:
javax.naming.NoInitialContextException: Cannot instantiate class: com.ibm.websphere.naming.WsnInitialContextFactory [Root exception is java.lang.ClassNotFoundException: com.ibm.websphere.naming.WsnInitialContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at javax.naming.directory.InitialDirContext.<init>(Unknown Source)
at PtpReceiver1.main(PtpReceiver1.java:42)
Caused by: java.lang.ClassNotFoundException: com.ibm.websphere.naming.WsnInitialContextFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
... 6 more
Any one can help me to over come this problem.Thanks in Advance.
Venkat. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Jan 26, 2006 1:50 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Try using the File environment.
To do what you are trying you need the EJB client for WAS and the
CLASSPATH for that one is nearly as impressive as the classpath for WAS.
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
venkat.rajm |
Posted: Fri Jan 27, 2006 1:37 am Post subject: |
|
|
Newbie
Joined: 04 Dec 2005 Posts: 7
|
Thank you for giving Reply. |
|
Back to top |
|
 |
venkat.rajm |
Posted: Fri Jan 27, 2006 4:03 am Post subject: |
|
|
Newbie
Joined: 04 Dec 2005 Posts: 7
|
Hi all,
In websphere Application server, i have setted Additional Properties for WebSphere MQ Queue Connection Factories and WebSphere MQ Queue Destinations.
But i am not sure about this , any one can help me to over come this problem. where i can find this configuration material.
I have some information but it's not complete. can any one send this material.
Thanks in Advance,
venkat |
|
Back to top |
|
 |
vennela |
Posted: Fri Jan 27, 2006 9:47 am Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
Where is your program running?
Stand-alone java program or program running in WAS |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Jan 27, 2006 1:02 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
vennela wrote: |
Where is your program running?
Stand-alone java program or program running in WAS |
Quote: |
javax.naming.NoInitialContextException: Cannot instantiate class: com.ibm.websphere.naming.WsnInitialContextFactory [Root exception is java.lang.ClassNotFoundException: com.ibm.websphere.naming.WsnInitialContextFactory]
|
So I have to say obviously outside of WAS. _________________ MQ & Broker admin |
|
Back to top |
|
 |
|