ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » problem connecting MQSever using client JMS

Post new topic  Reply to topic
 problem connecting MQSever using client JMS « View previous topic :: View next topic » 
Author Message
venkat.rajm
PostPosted: Thu Jan 26, 2006 6:40 am    Post subject: problem connecting MQSever using client JMS Reply with quote

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
View user's profile Send private message Send e-mail
fjb_saper
PostPosted: Thu Jan 26, 2006 1:50 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
venkat.rajm
PostPosted: Fri Jan 27, 2006 1:37 am    Post subject: Reply with quote

Newbie

Joined: 04 Dec 2005
Posts: 7

Thank you for giving Reply.
Back to top
View user's profile Send private message Send e-mail
venkat.rajm
PostPosted: Fri Jan 27, 2006 4:03 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
vennela
PostPosted: Fri Jan 27, 2006 9:47 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
fjb_saper
PostPosted: Fri Jan 27, 2006 1:02 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » problem connecting MQSever using client JMS
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.