查询Java Space连接?

时间:2011-12-15 09:28:41

标签: java javaspaces

代码示例:

    ServiceTemplate tmp1 = new ServiceTemplate(null, classes, null);

    try {

    /*      if(System.getSecurityManager() == null)

            System.setSecurityManager(new RMISecurityManager());*/

        thisIp = InetAddress.getLocalHost();
        LookupLocator locator = new LookupLocator("jini://"+thisIp.getHostName().toString());
        ServiceRegistrar sr = locator.getRegistrar();
        JavaSpace space = (JavaSpace)sr.lookup(tmp1);
        System.out.println("Success");

    } 

在[ServiceRegistrar sr = locator.getRegistrar();]遇到错误 哪个州

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:519)
at java.net.Socket.connect(Socket.java:469)
at java.net.Socket.<init>(Socket.java:366)
at java.net.Socket.<init>(Socket.java:209)
at net.jini.core.discovery.LookupLocator.getRegistrar(LookupLocator.java:328)
at net.jini.core.discovery.LookupLocator.getRegistrar(LookupLocator.java:286)
at MessageEntry.main(MessageEntry.java:34)

我是JavaSpace技术的新手,请帮助我。

提前感谢

Jeetesh.N

1 个答案:

答案 0 :(得分:2)

ConnectException是一个非常基本的错误,这意味着您的Java进程无法建立到目标计算机和端口的套接字连接,因为该计算机不接受目标端口上的连接。在这种情况下,它几乎肯定会尝试使用默认的JINI端口连接到您的localhost IP地址。

我建议此错误表示您在执行代码时没有在您的计算机上运行JINI服务/注册商。