Java RMI cannot bind server

旧街凉风 提交于 2019-12-01 04:16:41
user1766585

FWIW

I upgraded from JDK1.6.0_33 to 1.7.0_21 and had the same problem. I found this document and resolved the problem by starting rmiregistry with:

rmiregistry -J-Djava.rmi.server.useCodebaseOnly=false

tomsky

So, quick summary of the problem and the solution:

If you're running on JDK 7.1/ 6.29 (possible some other version) RMI server will not bind if you set its codebase to the file or directory on your hard disk. The same code works just fine under older version of JDK (tested on 6.24). Thanks for your help!

user207421

The underlying problem here is that the RMI Registry is running under a SecurityManager and its .policy file doesn't grant java.io.FilePermission" "\D:\uni\YEAR 3\Enterprise Programming\java\czat solution 2\bin\-" "read".

The clue to that is that this is a ServerException, i.e. thrown at the target of the call, and that the call itself is rebind().

See this post for an explanation.

Ruben Bhattacharya

Yes this problem occurs in Java 1.7 and above. So always go through the enhancements document if you upgrade your Java version. It is a fairly simple solution. You just need to start the rmiregistry in a different way.

Go through this document- http://docs.oracle.com/javase/7/docs/technotes/guides/rmi/enhancements-7.html

asura

Have you tried to explicitly give access to the file using the *.policy file? as described on http://docs.oracle.com/javase/7/docs/technotes/guides/security/permissions.html

grant codebase "file:/path/to/code" {
    permission java.io.FilePermission "\D:\uni\YEAR 3\Enterprise Programming\java\czat solution 2\bin\-", "read";
}

I have the same issue with openjdk... probably caused by this commit: http://hg.openjdk.java.net/jdk7u/jdk7u-gate/jdk/rev/7ed2fd310470

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!