我正在尝试将现有项目转移到新的(linux)服务器环境(请注意,我无法直接访问代码,也不了解该项目的总体情况 - 这是一个很好的开始),在启动项目时我收到以下错误:
Exception in thread "main" javax.naming.CommunicationException: Could not obtain connection to any of these urls: <servername>:1459 [Root exception is javax.naming.CommunicationException: Failed to connect to server <servername>:1459 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server <servername>:1459 [Root exception is java.net.ConnectException: Connection refused]]]
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1562)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:634)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at org.jboss.Shutdown.main(Shutdown.java:214)
Caused by: javax.naming.CommunicationException: Failed to connect to server <servername> [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server <servername>:1459 [Root exception is java.net.ConnectException: Connection refused]]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:274)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1533)
... 4 more
Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server <servername>:1459 [Root exception is java.net.ConnectException: Connection refused]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:248)
... 5 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at java.net.Socket.<init>(Socket.java:375)
at java.net.Socket.<init>(Socket.java:276)
at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:84)
at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:77)
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:244)
... 5 more
现在,我打开了有问题的端口,看看这样做是否有任何变化,可惜什么都没有发生。
很抱歉信息如此模糊,但这确实是我所知道的全部,如果您知道这里可能出了什么问题,我会很乐意提供我所能提供的。
问候,
丹尼斯
答案1
很简单,没有人监听端口 1459。您配置的 jboss 与之前的设置不完全相同。以下是各种 jboss 版本的默认设置http://shrubbery.mynetgear.net/c/display/W/JBoss+Ports和https://docs.jboss.org/author/display/AS7/Interfaces+and+ports?_sscc=t
以及文章摘录:
JBoss 7.x 端口
在 standalone.xml 中定义(或者您用于启动 jboss 的内容)
<socket-binding name="jndi" port="1099"/>
<socket-binding name="jmx-connector-registry" port="1090"/>
<socket-binding name="jmx-connector-server" port="1091"/>
<socket-binding name="http" port="8080"/>
<socket-binding name="https" port="8443"/>
<socket-binding name="jacorb" port="3528"/>
<socket-binding name="jacorb-ssl" port="3529"/>
<socket-binding name="osgi-http" port="8090"/>
<socket-binding name="remoting" port="4447"/>
<socket-binding name="txn-recovery-environment" port="4712"/>
<socket-binding name="txn-status-manager" port="4713"/>
<socket-binding name="messaging" port="5445"/>
<socket-binding name="messaging-throughput" port="5455"/>
</socket-binding-group>
JBoss 6.X 端口 大多数默认端口都列在 server/default/conf/bindingservice.beans/META-INF/bindings-jboss-beans.xml 中。
1090 RMI/JRMP for Remote JMX
1091 RMI server socket
1098 Naming Service - RMI requests from client proxies
1099 Naming Service - Main port
3873 EJB3 Remoting Connector
4446 JBoss Remoting Connector - Unified Invoker
4712 JBossTS Recovery Manager
4713 JBossTS Transaction Status Manager
4714 JBossTS - used to create a unique process id
5445 HornetQ
5455 Socket for HornetQ throughput connection factory
5500 Non-SSL Remoting
5501 SSL Remoting
8009 AJP Port
8080 HTTP Port
8083 Dynamic class and resource loading
JBoss 4.x 端口
1099 ./conf/jboss-service.xml or ./naming.sar/META-INF/jboss-service.xml Bootstrap JNP port.
1098 (anon) ./conf/jboss-service.xml or ./naming.sar/META-INF/jboss-service.xml RMI naming service port. Use '0' for an anonymous port.
4444 ./conf/jboss-service.xml or ./deploy/invokers-service.xml RMI/JRMP invoker port
4445 ./conf/jboss-service.xml or ./deploy/invokers-service.xml Pooled invoker
8083 ./conf/jboss-service.xml or ./deploy/dynclassloader-service.xml RMI dynamic class loader port
8080 ./deploy/jbossweb-tomcat55.sar/server.xml HTTP port for the web container
8009 ./deploy/jbossweb-tomcat55.sar/server.xml AJP port for the web container
8093 ./deploy/jms/uil2-service.xml UIL for JMS.
8443 (optional) ./deploy/jbossweb-tomcat55.sar/server.xml HTTPS port for the web container
答案2
我们从您的应用程序异常中看到,它正在尝试连接端口 1459 上的某个服务器,并且失败的原因是Connection refused
。
这可能有两个原因:
- 最有可能的情况是:远程服务未运行。要解决此问题,请启动远程服务。
- 可能性较小:远程服务受防火墙保护。要解决此问题,请打开防火墙。