java.rmi.ConnectException:连接拒绝主机192.168.56.1

时间:2014-11-23 12:20:59

标签: java rmi

我尝试使用命令提示符在Windows8系统上安装opensource软件。 我之前从未做过类似的事情,而且我使用RMI的经验也不是很丰富。我需要一些帮助来解决我得到的异常错误。 这是我遵循的程序:

我已经像这样设置了一个CLASSPATH

  set CLASSPATH=C:\kuwaiba7\service\lib\PersistenceAbstractionAPI.jar;C:\kuwaiba7\service\lib\PersistenceServiceRemoteInterfaces.jar 

然后我启动RMI注册表:

  start "C:\Program Files\Java\jdk1.7.0_71\bin\rmiregistry.exe

将打开一个新的命令提示符窗口。在此窗口中,我为PersistenceService运行以下命令:

  C:\kuwaiba7\service>java -Djava.rmi.server.codebase="file:/C:/kuwaiba7/service/l
ib/PersistenceAbstractionAPI.jar file:/C:/kuwaiba7/service/lib/PersistenceServiceRemoteInterfaces.jar" -jar PersistenceService.jar

第一行显示已建立与数据库的连接,但后来出现了:java.rmi.ConnectException错误。

  [Sun Nov 23 13:57:02 EET 2014] Current working directory: C:\kuwaiba7\service
  [Sun Nov 23 13:57:02 EET 2014] Establishing connection to the database...
  [Sun Nov 23 13:57:03 EET 2014] Connection established
  EmbeddedGraphDatabase [C:\kuwaiba7\service\target\kuwaiba.db]
  [Sun Nov 23 13:57:04 EET 2014] Registry obtained
  java.rmi.ConnectException: Connection refused to host: 192.168.56.1; nested exception is:
    java.net.ConnectException: Connection refused: connect
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
    at sun.rmi.server.UnicastRef.newCall(Unknown Source)
    at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
    at org.kuwaiba.persistenceservice.Main.main(Main.java:72)
 Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source)
    at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source)
    ... 6 more
    [Sun Nov 23 13:57:05 EET 2014] Abnormal program termination. See log file for  details

我的问题是: 1)如何确定RMI正确运行? 2)我得到的这个异常是否意味着我的RMI没有运行? 3)如何在命令提示符中解决此异常错误?

我还想提一下,在设置类路径之前我遇到了另一个错误:      java.rmi.serverException      java.rmi.unmarshalException      抛出java.lang.ClassNotFoundException

设置类路径后,我停止了这些错误。

我会对此提出任何帮助。正如我所提到的,我在使用RMI方面经验不足,请耐心等待! :)

由于 迪米瑞斯

1 个答案:

答案 0 :(得分:2)

我正在启动,然后使用为注册表打开的命令提示符窗口停止注册表。 EJP在上面的评论中非常清楚地解释了这一点。 感谢。