|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
jms client giving javax.naming.ServiceUnavailableException |
« View previous topic :: View next topic » |
Author |
Message
|
venkat.rajm |
Posted: Thu Feb 02, 2006 7:34 am Post subject: jms client giving javax.naming.ServiceUnavailableException |
|
|
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 6.0
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 and also added
INITIAL_CONTEXT_FACTORY=com.sun.jndi.ldap.LdapCtxFactory
PROVIDER_URL=ldap://IMCTRITEK/1414 values in jmsAdmin file which is bin folder
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 = "java:comp/env/jms/recivequeue";
String qcfName = "java:comp/env/jms/nb21queueconnectionfactory" ;
Context jndiContext = null;
QueueConnectionFactory queueConnectionFactory = null;
QueueConnection queueConnection = null;
QueueSession queueSession = null;
Queue queue = null;
QueueReceiver queueReceiver = null;
TextMessage message = null;
/* Provider url
/For Persistent Name Server- iiop://iiopservername/contextname
/For LDAP Server use ldap//cn=ContextName,o=OrganizationalSuffix,c=coutrysuffix
eg. ldap://machineName/cn=ptpCtx,o=itso,c=uk
*/
String providerUrl = "ldap://192.168.0.60:1414" ;
String initialContextFactory = "com.sun.jndi.ldap.LdapCtxFactory";
/**
* Step 2 set up Initial Context for JNDI lookup
*/
try{
Hashtable env = new Hashtable() ;
env.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory) ;
env.put(Context.PROVIDER_URL , providerUrl );
// env.put(Context.REFERRAL, "throw") ;
jndiContext = new InitialDirContext(env);
/**
* Step 3 get the QueueConnectionFactory from the JNDI Namespace
*/
queueConnectionFactory = (QueueConnectionFactory)jndiContext.lookup(qcfName);
/**
* Step 4 get the Queue Object from the JNDI Name space
*/
queue = (Queue)jndiContext.lookup(queueName);
/**
* Step 5 Create a QueueConnection using the QueueConnectionFactory
*/
queueConnection = queueConnectionFactory.createQueueConnection();
/*
*Step 6 Connections are always created in stopped mode. You have to Explicitly
start them. Start the queueConnection
*/
queueConnection.start();
/**
* Step 7 Create a queueSession object from the QueueConnection
*/
queueSession = queueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
/**
* Step 8 Create a QueueReceiver from the queueSession
*/
queueReceiver = queueSession.createReceiver(queue);
/**
* Step 9 Receive Messages. Here we are implementing a synchronous message
receiver. The receive call is in a loop so that it would process all the
available messages in the 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;
}
/**
* Step 10 Close the connections
*/
queueConnection.close();
}
catch(Exception e){
e.printStackTrace();
}
}
}
Here my Exception:
javax.naming.ServiceUnavailableException: 192.168.0.60:1414; socket closed
at com.sun.jndi.ldap.Connection.readReply(Unknown Source)
at com.sun.jndi.ldap.LdapClient.ldapBind(Unknown Source)
at com.sun.jndi.ldap.LdapClient.authenticate(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.connect(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.<init>(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(Unknown Source)
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)
Thanks in advance
venkat |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Feb 02, 2006 7:42 am Post subject: Re: jms client giving javax.naming.ServiceUnavailableExcepti |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
venkat.rajm wrote: |
In websphere Application server, i have setted Additional Properties for WebSphere MQ Queue Connection Factories and WebSphere MQ Queue Destinations and also added
INITIAL_CONTEXT_FACTORY=com.sun.jndi.ldap.LdapCtxFactory
PROVIDER_URL=ldap://IMCTRITEK/1414 values in jmsAdmin file which is bin folder |
Why aren't you using the WebSphere App Server JNDI? Why are you trying to use an LDAP context factory with a "jmsAdmin file", whatever that is...? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|