dcsimg
javax.naming.CommunicationException
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Sunday, June 22, 2003 11:58 PM

Untitled Document I have written a jms program(publisher/subscriber). It can work on the same pc, the publisher can send the message to subscriber successfully. But when i try to work on different pc, i get a error message "javax.naming.CommunicationException [root exception is java.rmi.ConnectionException: Connection refused to host: 127.0.0.1; nested exception is: java.net.ConnectException: Connection refuesed: connect]. How can solve this problem? Which config file should be edited? <%@ page import = "javax.naming.Context" %> <%@ page import = "javax.naming.InitialContext" %> <%@ page import = "javax.naming.NamingEx   More>>
Untitled Document

I have written a jms program(publisher/subscriber). It can work on the same pc, the publisher can send the message to subscriber successfully. But when i try to work on different pc, i get a error message "javax.naming.CommunicationException [root exception is java.rmi.ConnectionException: Connection refused to host: 127.0.0.1; nested exception is: java.net.ConnectException: Connection refuesed: connect]. How can solve this problem? Which config file should be edited?










<%@ page import = "javax.naming.Context" %>

<%@ page import = "javax.naming.InitialContext" %>

<%@ page import = "javax.naming.NamingException" %>

<%@ page import = "java.util.Hashtable" %>



<%@ page import = "javax.jms.TopicConnectionFactory" %>

<%@ page import = "javax.jms.TopicConnection" %>

<%@ page import = "javax.jms.TopicSession" %>

<%@ page import = "javax.jms.TopicPublisher" %>

<%@ page import = "javax.jms.Topic" %>

<%@ page import = "javax.jms.TextMessage" %>

<%@ page import = "javax.jms.Session" %>

<%@ page import = "javax.jms.JMSException" %>















<%

TopicPublisher topicPublisher;

TopicConnection topicConnection;

TopicSession topicSession;

Topic topic;



try{

Hashtable env = new Hashtable();

env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");

env.put(Context.PROVIDER_URL,"jnp://192.168.18.40:1099");

Context context = new InitialContext(env);



TopicConnectionFactory topicFactory = (TopicConnectionFactory)context.lookup("ConnectionFactory");

topicConnection = topicFactory.createTopicConnection();

topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);

topic = (Topic)context.lookup("topic/testTopic");

topicPublisher = topicSession.createPublisher(topic);



for (int i = 1; i < 11; i++) {

String msg = "Hello World no. " + i;

out.println("Publishing message: " + msg);

TextMessage message = topicSession.createTextMessage();

message.setText(msg);


topicPublisher.publish(topic, message);

}



topicSession.close();

topicConnection.close();

} catch (NamingException nEx){

System.out.println(nEx.toString() + "
Does the queue exist?");

//System.exit(1);

}


%>








Thanks a lot!!!

   <<Less
About | Sitemap | Contact