RMI注册表:在给定时间后新启动时,服务器无法连接到RMI注册表

使用Java RMI遇到一个奇怪的问题。 我有一个客户端服务器体系结构,其中单个客户端应根据可用性将消息调度到多个服务器实例。 为了进行通信,使用了RMI。启动服务器时,在JVM中运行的进程将启动RMIRegistry,随后又启动了多个服务器进程,并且在RMIRegistry中注册没有问题。

INFO  org.springframework.remoting.rmi.RmiServiceExporter - Binding service '##' to RMI registry:RegistryImpl_Stub[UnicastRef [liveRef: [endpoint:[192.168.165.218:1098](remote),objID:[0:0:0,0]]]] 

在给定时间之后,链接到RMI注册表的进程将停止,并开始新的进程。这些新进程将无法在RMI注册表中注册自己,说:

org.springframework.remoting.RemoteConnectFailureException: Could not connect to remote service [rmi://localhost:1098/###]; nested exception is java.rmi.connectexception: Connection refused to host: 192.168.165.218; nested exception is: 
    java.net.connectexception: Connection refused: connect
    at org.springframework.remoting.rmi.rmiclientInterceptorUtils.convertRmiaccessException(rmiclientInterceptorUtils.java:190)[57:org.springframework.context:3.0.7.RELEASE]
    at org.springframework.remoting.rmi.rmiclientInterceptor.doInvoke(rmiclientInterceptor.java:347)[57:org.springframework.context:3.0.7.RELEASE]
    at org.springframework.remoting.rmi.rmiclientInterceptor.invoke(rmiclientInterceptor.java:259)[57:org.springframework.context:3.0.7.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodinvocation.proceed(ReflectiveMethodinvocation.java:172)[56:org.springframework.aop:3.0.7.RELEASE]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)[56:org.springframework.aop:3.0.7.RELEASE]
    at com.sun.proxy.$Proxy37.getProcessId(Unknown Source)[79:##]
    at ###
    at ###
Caused by: java.rmi.connectexception: Connection refused to host: 192.168.165.218; nested exception is: 
    java.net.connectexception: Connection refused: connect
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)[:1.7.0_51]
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)[:1.7.0_51]
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)[:1.7.0_51]
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:129)[:1.7.0_51]
    at java.rmi.server.RemoteObjectinvocationHandler.invokeRemoteMethod(RemoteObjectinvocationHandler.java:194)[:1.7.0_51]
    at java.rmi.server.RemoteObjectinvocationHandler.invoke(RemoteObjectinvocationHandler.java:148)[:1.7.0_51]
    at com.sun.proxy.$Proxy36.invoke(Unknown Source)[57:org.springframework.context:3.0.7.RELEASE]
    at org.springframework.remoting.rmi.rmiclientInterceptor.doInvoke(rmiclientInterceptor.java:398)[57:org.springframework.context:3.0.7.RELEASE]
    at org.springframework.remoting.rmi.rmiclientInterceptor.doInvoke(rmiclientInterceptor.java:344)[57:org.springframework.context:3.0.7.RELEASE]
    ... 21 more
Caused by: java.net.connectexception: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)[:1.7.0_51]
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)[:1.7.0_51]
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)[:1.7.0_51]
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)[:1.7.0_51]
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)[:1.7.0_51]
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)[:1.7.0_51]
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)[:1.7.0_51]
    at java.net.Socket.connect(Socket.java:579)[:1.7.0_51]
    at java.net.Socket.connect(Socket.java:528)[:1.7.0_51]
    at java.net.Socket.<init>(Socket.java:425)[:1.7.0_51]
    at java.net.Socket.<init>(Socket.java:208)[:1.7.0_51]
    at sun.rmi.transport.proxy.RMIDirectsocketFactory.createSocket(RMIDirectsocketFactory.java:40)[:1.7.0_51]
    at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:147)[:1.7.0_51]
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)[:1.7.0_51]
    ... 29 more

我非常感谢您的帮助

欢呼 约翰

zxofxop 回答:RMI注册表:在给定时间后新启动时,服务器无法连接到RMI注册表

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2893089.html

大家都在问