小弟在做JMS測試時
用其它的WIN版本(如VISTA)連WIN2008R2都正常
可是用WIN7連就出包
它是寫拒決存取,錯誤如下,其中一段
Caused by: java.net.ConnectException: Connection refused: connect
at sun.nio.ch.Net.connect(Native Method)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:507)
at com.sun.corba.ee.impl.orbutil.ORBUtility.openSocketChannel(ORBUtility.java:106)
at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:325)
... 14 more
程式碼如下
import java.util.Hashtable;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jms.*;
import javax.naming.*;
//import javax.jndi.Referenceable;
public class messageProducer {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Hashtable properties = new Hashtable();
properties.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.enterprise.naming.SerialInitContextFactory");
properties.put(Context.PROVIDER_URL, "iiop://192.168.1.51:7676");
try {
// 建立 Context
InitialContext jndiContext = new InitialContext(properties);
System.out.println("JMS inital well...");
// 查找 ConnectionFactory
ConnectionFactory connectionFactory = (ConnectionFactory) jndiContext.lookup("TestFactor123");
System.out.println("JMS factory found...");
try {
// Making a connection
Connection connection = connectionFactory.createConnection();
System.out.println("JMS connection established...");
// Intial session
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
System.out.println("Session created...");
// Find destination
Destination pipe = (Destination) jndiContext.lookup("TOPIC");
MessageProducer messageProducer = session.createProducer(pipe);
TextMessage message = session.createTextMessage();
message.setText("Second line");
messageProducer.send(message);
session.close();
System.out.println("Session closed...");
connection.close();
System.out.println("JMS connection closed...");
} catch (JMSException ex) {
Logger.getLogger(messageProducer.class.getName()).log(Level.SEVERE, null, ex);
}
} catch (NamingException ex) {
Logger.getLogger(messageProducer.class.getName()).log(Level.SEVERE, null, ex);
}
System.exit(0);
}
}
有人有試過這方面的設定,在環境上嗎