当前位置: 技术问答>java相关
关于rmi的问题
来源: 互联网 发布时间:2015-08-30
本文导语: 我在Thinking in java中的rmi例子中, 已经做到了这些: 1。创建了接口PerfectTimeI.java,和PerfectTime.java,并且编译成了.class文件 2。用rmic已经创建了stub和skel的.class文件。 3。已经启动了rmiregistry(用默认端口1099) 但是...
我在Thinking in java中的rmi例子中,
已经做到了这些:
1。创建了接口PerfectTimeI.java,和PerfectTime.java,并且编译成了.class文件
2。用rmic已经创建了stub和skel的.class文件。
3。已经启动了rmiregistry(用默认端口1099)
但是在执行PerfectTime时在Naming.bind中出现了下面的问题:
抛出了java.security.AccessControlException异常,堆栈如下:
java.security.AccessControlException: access denied (java.net.SocketPermission e
cho's resolve)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getByName(Unknown Source)
at java.net.Socket.(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown S
ource)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown S
ource)
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.bind(Unknown Source)
at java.rmi.Naming.bind(Unknown Source)
at myrmi.ptime.PerfectTime.main(PerfectTime.java:22)
哪位大侠知道是什么原因,并且如何改。
对了,我在bind时只是使用了Naming.bind("PerfectTime", pt);应该是默认的localhost,我也使用过"//localhost/PerfectTime",和“//computername/PerfectTime”都会出现同样问题。
已经做到了这些:
1。创建了接口PerfectTimeI.java,和PerfectTime.java,并且编译成了.class文件
2。用rmic已经创建了stub和skel的.class文件。
3。已经启动了rmiregistry(用默认端口1099)
但是在执行PerfectTime时在Naming.bind中出现了下面的问题:
抛出了java.security.AccessControlException异常,堆栈如下:
java.security.AccessControlException: access denied (java.net.SocketPermission e
cho's resolve)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getByName(Unknown Source)
at java.net.Socket.(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown S
ource)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown S
ource)
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.bind(Unknown Source)
at java.rmi.Naming.bind(Unknown Source)
at myrmi.ptime.PerfectTime.main(PerfectTime.java:22)
哪位大侠知道是什么原因,并且如何改。
对了,我在bind时只是使用了Naming.bind("PerfectTime", pt);应该是默认的localhost,我也使用过"//localhost/PerfectTime",和“//computername/PerfectTime”都会出现同样问题。
|
建一个XXX.POLICY文件,内容如下:
grant
{ permission java.net.SocketPermission
"*:1024-", "connect";
}
执行时用:
java -Djava.security.policy=xxx.policy YourClass
如果还有错的话,把文件改为如下:
grant {
permission java.security.AllPermission;
};
grant
{ permission java.net.SocketPermission
"*:1024-", "connect";
}
执行时用:
java -Djava.security.policy=xxx.policy YourClass
如果还有错的话,把文件改为如下:
grant {
permission java.security.AllPermission;
};
|
需要一个policy文件。
|
你的policy文件是否开放了权限。