当前位置: 技术问答>java相关
rmi问题,急需解决,一定给分
来源: 互联网 发布时间:2015-02-24
本文导语: 我刚做了一个rmi程序,返回一个结果集,程序编译完全成功,但是用 java -Djava.security.policy=policy.java HelloImpl打开服务器端程序的时候出现一下的问题: C:aaa>java -Djava.security.policy=policy.java HelloImpl HelloImpl err:Connection ...
我刚做了一个rmi程序,返回一个结果集,程序编译完全成功,但是用
java -Djava.security.policy=policy.java HelloImpl打开服务器端程序的时候出现一下的问题:
C:aaa>java -Djava.security.policy=policy.java HelloImpl
HelloImpl err:Connection refused to host: localhost; nested exception is:
java.net.ConnectException: Connection refused: connect
java.rmi.ConnectException: Connection refused to host: localhost; nested excepti
on is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:570)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:188
)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:174)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:316)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:162)
at HelloImpl.main(HelloImpl.java:43)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:296)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:162)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:149)
at java.net.Socket.connect(Socket.java:430)
at java.net.Socket.connect(Socket.java:379)
at java.net.Socket.(Socket.java:293)
at java.net.Socket.(Socket.java:121)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirect
SocketFactory.java:25)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMaster
SocketFactory.java:125)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:565)
... 6 more
java -Djava.security.policy=policy.java HelloImpl打开服务器端程序的时候出现一下的问题:
C:aaa>java -Djava.security.policy=policy.java HelloImpl
HelloImpl err:Connection refused to host: localhost; nested exception is:
java.net.ConnectException: Connection refused: connect
java.rmi.ConnectException: Connection refused to host: localhost; nested excepti
on is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:570)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:188
)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:174)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:316)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:162)
at HelloImpl.main(HelloImpl.java:43)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:296)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:162)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:149)
at java.net.Socket.connect(Socket.java:430)
at java.net.Socket.connect(Socket.java:379)
at java.net.Socket.(Socket.java:293)
at java.net.Socket.(Socket.java:121)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirect
SocketFactory.java:25)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMaster
SocketFactory.java:125)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:565)
... 6 more
|
Are you sure you have server running. To me, you either don't have rmiRegistry or server
|
好象安全策略没有配置好, 没有访问端口的权限
|
AllPermission 就可以了
|
permission java.security.AllPermission;
一句就行!
一句就行!