我在Azure Windows VM上安装了GlassFish 4.0 Web服务器,该服务器将用作JMS消息代理。
在GlassFish上我有2个资源:
连接工厂:GFConnectionFactory,类型为javax.jms.TopicConnectionFactory
目的地:myTopic,类型为javax.jms.Topic
在我的VM的网络安全组中,我有以下入站规则:NSG inbound rules
当我启动VM + Glassfish并尝试查找主题时,我收到以下错误:
org.omg.CORBA.COMM_FAILURE: FINE: 00410001: Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: localhost; port: 3700 vmcid: OMG minor code: 1 completed: No
at com.sun.proxy.$Proxy17.connectFailure(Unknown Source)
at com.sun.corba.ee.impl.transport.ConnectionImpl.<init>(ConnectionImpl.java:253)
at com.sun.corba.ee.impl.transport.ConnectionImpl.<init>(ConnectionImpl.java:276)
at com.sun.corba.ee.impl.transport.ContactInfoImpl.createConnection(ContactInfoImpl.java:129)
at com.sun.corba.ee.impl.protocol.ClientRequestDispatcherImpl.beginRequest(ClientRequestDispatcherImpl.java:243)
at com.sun.corba.ee.impl.protocol.ClientDelegateImpl.request(ClientDelegateImpl.java:227)
at com.sun.corba.ee.impl.protocol.ClientDelegateImpl.is_a(ClientDelegateImpl.java:392)
at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl.java:130)
at org.omg.CosNaming.NamingContextHelper.narrow(NamingContextHelper.java:69)
at com.sun.enterprise.naming.impl.SerialContext$ProviderCacheKey.getNameService(SerialContext.java:1205)
at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:393)
at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:329)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:477)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at gla.prisoft.monitor.PSatMonitor.main(PSatMonitor.java:45)
Caused by: java.lang.RuntimeException: java.net.ConnectException: Connection refused: connect
at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:344)
at com.sun.corba.ee.impl.transport.ConnectionImpl.<init>(ConnectionImpl.java:250)
... 14 more
Caused by: java.net.ConnectException: Connection refused: connect
at sun.nio.ch.Net.connect0(Native Method)
at sun.nio.ch.Net.connect(Net.java:454)
at sun.nio.ch.Net.connect(Net.java:446)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:648)
at com.sun.corba.ee.impl.misc.ORBUtility.openSocketChannel(ORBUtility.java:110)
at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:329)
... 15 more
以下是代码:
public static Context getInitialContext() throws NamingException{
Properties properties = new Properties();
properties.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
properties.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
//properties.setProperty("java.naming.provider.url", "iiop://localhost:3700");
//properties.setProperty("java.naming.provider.url", "iiop://13.90.159.219:3700");
properties.setProperty("java.naming.provider.url", "13.90.159.219:3700");
// properties.setProperty("org.omg.CORBA.ORBInitialHost", "13.90.159.219");
// properties.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
return new InitialContext(properties);
}
public static void main(String []args ) throws NamingException{
String topicname = "myTopic";
Context initialContext = getInitialContext();
topic = (Topic)initialContext.lookup(topicname);
jmsContext = ((ConnectionFactory)initialContext.lookup("GFConnectionFactory")).createContext();
我不明白为什么它仍在尝试连接到localhost而不是我指定的IP。
是VM配置是问题(我尝试打开所有端口并关闭防火墙等)。我可以通过http://13.90.159.219:3700从本地计算机上的浏览器成功连接与&#34; telnet 13.90.159.219 3700&#34;来自cmd。
我也尝试将主题指定为&#34; corbaname:iiop:host:port#a / b / name&#34;。
非常感谢任何有用的建议!
答案 0 :(得分:0)
根据我的经验,我认为在NSG中不允许使用GlassFish所需的一些帖子,如你所说,如果打开所有端口并关闭防火墙(我认为你说的防火墙是在Windows上),那么连接的工作原理。
我的建议是你可以尝试使用命令jps
&amp; Azure VM上的netstat
如下所示,以发现GlassFish中使用的所有端口,然后允许这些端口在NSG&amp ;;中进行入站连接。 Windows防火墙。
jps
将所有Java进程ID列为LIST 1
。netstat -apn
列出所有端口&amp; PID
的{{1}}为LISTEN
。然后,找出LIST 2
和{}中列出的PID
LIST 1
。 LIST 2
并允许他们加入NSG&amp; Windows防火墙。