rmi java.security.AccessControlException
我是 RIM 新手,目前正在学习 http:// java.sun.com/docs/books/tutorial/rmi/overview.html
我能够像这样启动服务器:
C:\Documents and Settings\myHome>java -cp c:\home\ann\src;c:\home\ann\public_ html\classes\compute.jar -Djava.rmi.server.codebase=file:/c:/home/ann/public_htm l/classes/compute.jar -Djava.rmi.server.hostname=localhost -Djava.security.polic y=c:\home\ann\policy\server.policy engine.ComputeEngine ComputeEngine bound
但是,当我尝试运行客户端时出现异常,
access: access allowed (java.lang.RuntimePermission createClassLoader) access: access allowed (java.lang.reflect.ReflectPermission suppressAccessChecks ) access: access allowed (java.lang.reflect.ReflectPermission suppressAccessChecks ) access: access allowed (java.lang.reflect.ReflectPermission suppressAccessChecks ) access: access allowed (java.lang.reflect.ReflectPermission suppressAccessChecks ) ComputePi exception: java.rmi.ServerException: RemoteException occurred in server thread; nested exce ption is: java.rmi.UnmarshalException: error unmarshalling arguments; nested excep tion is: java.lang.ClassNotFoundException: access to class loader denied at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source) at sun.rmi.transport.Transport$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Unknown Source) at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Sou rce) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Sour ce) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source ) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknow n Source) at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source) at sun.rmi.server.UnicastRef.invoke(Unknown Source) at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unkn own Source) at java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source) at $Proxy0.executeTask(Unknown Source) at client.ComputePi.main(ComputePi.java:27) Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested ex ception is: java.lang.ClassNotFoundException: access to class loader denied at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source) at sun.rmi.transport.Transport$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Unknown Source) at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Sou rce) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Sour ce) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source ) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: access to class loader denied at sun.rmi.server.LoaderHandler.loadClass(Unknown Source) at sun.rmi.server.LoaderHandler.loadClass(Unknown Source) at java.rmi.server.RMIClassLoader$2.loadClass(Unknown Source) at java.rmi.server.RMIClassLoader.loadClass(Unknown Source) at sun.rmi.server.MarshalInputStream.resolveClass(Unknown Source) at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source) at java.io.ObjectInputStream.readClassDesc(Unknown Source) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at sun.rmi.server.UnicastRef.unmarshalValue(Unknown Source) ... 10 more Caused by: java.security.AccessControlException: access denied (java.io.FilePerm ission \c:\home\jones\public_html\classes\- read) at java.security.AccessControlContext.checkPermission(Unknown Source) at java.security.AccessController.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPermission(Unknown Source) at sun.rmi.server.LoaderHandler$Loader.checkPermissions(Unknown Source) at sun.rmi.server.LoaderHandler$Loader.access$000(Unknown Source) ... 21 more
我相信问题是客户端策略文件客户端(如果我错了,请更正),正如我们从堆栈跟踪中看到的那样
Caused by: java.security.AccessControlException: access denied (java.io.FilePerm ission \c:\home\jones\public_html\classes\- read)
,但是,我的 client.policy 文件看起来像
grant codeBase "file:/c:/home/jones/public_html/classes/-" { permission java.security.AllPermission; }; grant{ permission java.net.SocketPermission "127.0.0.1:1024-65535", "connect,resolve"; };
CodeBase “file:/c:/home/jones/public_html/classes/-” 有 AllPermission。
那么,我是否将 codeBase 权限设置错误,因此客户端应用程序需要更多权限?
谢谢!!!
Update: if i move the client.policy file to C:\Program Files\Java\jre6\lib\security and i start the client with
C:\Documents and Settings\jianzhang>java -cp c:\home\jones\src;c:\home\jones\pub lic_html\classes\compute.jar -Djava.rmi.server.codebase=file:/c:/home/jones/publ ic_html/classes/ -Djava.security.policy=client.policy -Djava.security.debug=acce ss,failure client.ComputePi localhost 45
我遇到异常
ComputePi exception: java.security.AccessControlException: access denied (java.net.SocketPermission 1 27.0.0.1:1099 connect,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.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.(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.lookup(Unknown Source) at client.ComputePi.main(ComputePi.java:25)
但是,client.policy 文件已指定
grant{ permission java.net.SocketPermission "127.0.0.1:1024-65535", "connect,resolve"; };
Update with full stack trace Here is the full stack trace,
C:\home\jones\src>java -cp C:\home\jones\src;C:\home\jones\public_html\classes\c ompute.jar;C:\home\jones\public_html\classes -Djava.rmi.server.codebase=file:/C: /home/jones/public_html/classes/ -Djava.security.policy=client.policy -Djava.sec urity.debug=access,failure client.ComputePi localhost 45 access: access allowed (java.lang.reflect.ReflectPermission suppressAccessChecks ) access: access allowed (java.security.SecurityPermission getProperty.policy.expa ndProperties) access: access allowed (java.security.SecurityPermission getProperty.policy.igno reIdentityScope) access: access allowed (java.security.SecurityPermission getProperty.policy.allo wSystemProperty) access: access allowed (java.util.PropertyPermission sun.security.policy.utf8 re ad) access: access allowed (java.util.PropertyPermission sun.security.policy.numcach es read) access: access allowed (java.util.PropertyPermission java.security.policy read) access: access allowed (java.util.PropertyPermission user.dir read) access: access allowed (java.io.FilePermission C:\home\jones\src\client.policy r ead) access: access allowed (java.io.FilePermission client.policy read) access: access allowed (java.security.SecurityPermission getProperty.policy.url. 1) access: access allowed (java.util.PropertyPermission java.home read) access: access allowed (java.io.FilePermission C:\Program Files\Java\jre6\lib\se curity\java.policy read) access: access allowed (java.io.FilePermission C:\Program Files\Java\jre6\lib\se curity\java.policy read) access: access allowed (java.io.FilePermission C:\Program Files\Java\jre6\lib\se curity\java.policy read) access: access allowed (java.io.FilePermission C:\Program Files\Java\jre6\lib\se curity\java.policy read) access: access allowed (java.util.PropertyPermission java.ext.dirs read) access: access allowed (java.io.FilePermission C:\Program Files\Java\jre6\lib\ex t\* read) access: access allowed (java.io.FilePermission C:\WINDOWS\Sun\Java\lib\ext\* rea d) access: access allowed (java.security.SecurityPermission getProperty.policy.url. 2) access: access allowed (java.util.PropertyPermission user.home read) access: access allowed (java.io.FilePermission C:\Documents and Settings\anga ng\.java.policy read) access: access allowed (java.io.FilePermission C:\Documents and Settings\anga ng\.java.policy read) access: access allowed (java.io.FilePermission C:\Documents and Settings\anga ng\.java.policy read) access: access allowed (java.security.SecurityPermission getProperty.policy.url. 3) access: access allowed (java.util.PropertyPermission java.security.auth.policy r ead) access: access allowed (java.security.SecurityPermission getProperty.auth.policy .url.1) access: access allowed (java.lang.RuntimePermission accessClassInPackage.sun.sec urity.provider) access: access allowed (java.lang.reflect.ReflectPermission suppressAccessChecks ) access: access allowed (java.util.PropertyPermission java.security.egd read) access: access allowed (java.security.SecurityPermission getProperty.securerando m.source) access: access allowed (java.security.SecurityPermission putProviderProperty.SUN ) access: access allowed (java.lang.reflect.ReflectPermission suppressAccessChecks ) access: access allowed (java.lang.reflect.ReflectPermission suppressAccessChecks ) access: access allowed (java.util.PropertyPermission * read,write) access: access allowed (java.util.PropertyPermission os.arch read) access: access allowed (java.util.PropertyPermission java.net.preferIPv6Addresse s read) access: access allowed (java.lang.RuntimePermission loadLibrary.net) access: access allowed (java.io.FilePermission C:\Program Files\Java\jre6\bin\ne t.dll read) access: access allowed (java.util.PropertyPermission java.net.preferIPv4Stack re ad) access: access allowed (java.util.PropertyPermission impl.prefix read) access: access allowed (java.lang.reflect.ReflectPermission suppressAccessChecks ) access: access allowed (java.util.PropertyPermission sun.net.spi.nameservice.pro vider.1 read) access: access allowed (java.net.SocketPermission myComputer resolve) access: access allowed (java.security.SecurityPermission getProperty.networkaddr ess.cache.ttl) access: access allowed (java.util.PropertyPermission sun.net.inetaddr.ttl read) access: access allowed (java.security.SecurityPermission getProperty.networkaddr ess.cache.negative.ttl) access: access allowed (java.io.FilePermission C:\Documents and Settings\anga ng\Local Settings\Temp read) access: access allowed (java.io.FilePermission C:\Documents and Settings\anga ng\Local Settings\Temp read) access: access allowed (java.io.FilePermission C:\Documents and Settings\anga ng\Local Settings\Temp read) access: access allowed (java.io.FilePermission C:\Documents and Settings\anga ng\Local Settings\Temp read) access: access allowed (java.io.FilePermission C:\DOCUME~1\ang~1\LOCALS~1\Tem p read) access: access allowed (java.util.PropertyPermission java.rmi.server.hostname re ad) access: access allowed (java.io.FilePermission C:\home\jones\src read) access: access denied (java.net.SocketPermission myComputer resolve) java.lang.Exception: Stack trace at java.lang.Thread.dumpStack(Unknown Source) 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.getLocalHost(Unknown Source) at sun.rmi.transport.tcp.TCPEndpoint.(Unknown Source) at java.rmi.registry.LocateRegistry.getRegistry(Unknown Source) at java.rmi.registry.LocateRegistry.getRegistry(Unknown Source) at java.rmi.registry.LocateRegistry.getRegistry(Unknown Source) at client.ComputePi.main(ComputePi.java:24) access: access allowed (java.security.SecurityPermission getPolicy) access: access allowed (java.io.FilePermission C:\home\jones\src read) access: domain that failed ProtectionDomain (file:/C:/home/jones/src/ ) sun.misc.Launcher$AppClassLoader@1b90b39 java.security.Permissions@d70d7a ( (java.lang.RuntimePermission stopThread) (java.lang.RuntimePermission exitVM) (java.io.FilePermission \C:\home\jones\src\- read) (java.util.PropertyPermission line.separator read) (java.util.PropertyPermission java.vm.version read) (java.util.PropertyPermission java.vm.specification.version read) (java.util.PropertyPermission java.vm.specification.vendor read) (java.util.PropertyPermission java.vendor.url read) (java.util.PropertyPermission java.vm.name read) (java.util.PropertyPermission os.name read) (java.util.PropertyPermission java.vm.vendor read) (java.util.PropertyPermission path.separator read) (java.util.PropertyPermission java.specification.name read) (java.util.PropertyPermission os.version read) (java.util.PropertyPermission os.arch read) (java.util.PropertyPermission java.class.version read) (java.util.PropertyPermission java.version read) (java.util.PropertyPermission file.separator read) (java.util.PropertyPermission java.vendor read) (java.util.PropertyPermission java.vm.specification.name read) (java.util.PropertyPermission java.specification.version read) (java.util.PropertyPermission java.specification.vendor read) (java.net.SocketPermission localhost:1024- listen,resolve) ) access: access allowed (java.util.PropertyPermission java.rmi.server.useLocalHos tName read) access: access allowed (java.util.PropertyPermission sun.rmi.transport.logLevel read) access: access allowed (java.util.PropertyPermission sun.rmi.log.useOld read) access: access allowed (java.util.PropertyPermission java.util.logging.manager r ead) access: access allowed (java.lang.RuntimePermission setContextClassLoader) access: access allowed (java.lang.RuntimePermission shutdownHooks) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.PropertyPermission java.util.logging.config.cl ass read) access: access allowed (java.util.PropertyPermission java.util.logging.config.fi le read) access: access allowed (java.util.PropertyPermission java.home read) access: access allowed (java.io.FilePermission C:\Program Files\Java\jre6\lib\lo gging.properties read) access: access allowed (java.io.FilePermission C:\Program Files\Java\jre6\lib\lo gging.properties read) access: access allowed (java.io.FilePermission C:\Program Files\Java\jre6\lib\lo gging.properties read) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.PropertyPermission line.separator read) access: access allowed (java.util.PropertyPermission line.separator read) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.PropertyPermission sun.rmi.transport.tcp.logLe vel read) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.PropertyPermission sun.rmi.transport.tcp.maxCo nnectionThreads read) access: access allowed (java.util.PropertyPermission sun.rmi.transport.tcp.threa dKeepAliveTime read) access: access allowed (java.util.PropertyPermission sun.rmi.transport.proxy.log Level read) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.PropertyPermission sun.rmi.transport.proxy.con nectTimeout read) access: access allowed (java.util.PropertyPermission sun.rmi.transport.proxy.eag erHttpFallback read) access: access allowed (java.util.PropertyPermission http.proxyHost read) access: access allowed (java.util.PropertyPermission proxyHost read) access: access allowed (java.util.PropertyPermission java.rmi.server.disableHttp read) access: access allowed (java.util.PropertyPermission sun.rmi.transport.tcp.readT imeout read) access: access allowed (java.util.PropertyPermission sun.rmi.server.logLevel rea d) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.PropertyPermission java.rmi.server.ignoreStubC lasses read) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.PropertyPermission sun.rmi.client.logCalls rea d) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.PropertyPermission java.rmi.server.hostname re ad) access: access allowed (java.util.PropertyPermission sun.rmi.transport.connectio nTimeout read) access: access allowed (java.util.PropertyPermission sun.rmi.transport.tcp.hands hakeTimeout read) access: access allowed (java.util.PropertyPermission sun.rmi.transport.tcp.respo nseTimeout read) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.PropertyPermission sun.rmi.runtime.schedulerTh reads read) access: access allowed (java.lang.RuntimePermission sun.rmi.runtime.RuntimeUtil. getInstance) access: access allowed (java.net.SocketPermission localhost resolve) access: access allowed (java.lang.RuntimePermission loadLibrary.net) access: access allowed (java.io.FilePermission C:\Program Files\Java\jre6\bin\ne t.dll read) access: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve) java.lang.Exception: Stack trace at java.lang.Thread.dumpStack(Unknown Source) 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.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.(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.lookup(Unknown Source) at client.ComputePi.main(ComputePi.java:25) access: access allowed (java.security.SecurityPermission getPolicy) access: access allowed (java.io.FilePermission C:\home\jones\src read) access: domain that failed ProtectionDomain (file:/C:/home/jones/src/ ) sun.misc.Launcher$AppClassLoader@1b90b39 java.security.Permissions@77158a ( (java.lang.RuntimePermission stopThread) (java.lang.RuntimePermission exitVM) (java.io.FilePermission \C:\home\jones\src\- read) (java.util.PropertyPermission line.separator read) (java.util.PropertyPermission java.vm.version read) (java.util.PropertyPermission java.vm.specification.version read) (java.util.PropertyPermission java.vm.specification.vendor read) (java.util.PropertyPermission java.vendor.url read) (java.util.PropertyPermission java.vm.name read) (java.util.PropertyPermission os.name read) (java.util.PropertyPermission java.vm.vendor read) (java.util.PropertyPermission path.separator read) (java.util.PropertyPermission java.specification.name read) (java.util.PropertyPermission os.version read) (java.util.PropertyPermission os.arch read) (java.util.PropertyPermission java.class.version read) (java.util.PropertyPermission java.version read) (java.util.PropertyPermission file.separator read) (java.util.PropertyPermission java.vendor read) (java.util.PropertyPermission java.vm.specification.name read) (java.util.PropertyPermission java.specification.version read) (java.util.PropertyPermission java.specification.vendor read) (java.net.SocketPermission localhost:1024- listen,resolve) ) ComputePi exception: java.security.AccessControlException: access denied (java.net.SocketPermission 1 27.0.0.1:1099 connect,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.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.(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.lookup(Unknown Source) at client.ComputePi.main(ComputePi.java:25)
在第 80 行:
access: access allowed (java.net.SocketPermission myComputer resolve)
但是从第 99 行到第 111
access: access denied (java.net.SocketPermission myComputer resolve) java.lang.Exception: Stack trace at java.lang.Thread.dumpStack(Unknown Source) 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.getLocalHost(Unknown Source) at sun.rmi.transport.tcp.TCPEndpoint.(Unknown Source) at java.rmi.registry.LocateRegistry.getRegistry(Unknown Source) at java.rmi.registry.LocateRegistry.getRegistry(Unknown Source) at java.rmi.registry.LocateRegistry.getRegistry(Unknown Source) at client.ComputePi.main(ComputePi.java:24)
行问题已解决,请参阅 我的另一篇文章
I am new to RIM, and currently taking the tutorial at http://java.sun.com/docs/books/tutorial/rmi/overview.html
I am able to start server like:
C:\Documents and Settings\myHome>java -cp c:\home\ann\src;c:\home\ann\public_ html\classes\compute.jar -Djava.rmi.server.codebase=file:/c:/home/ann/public_htm l/classes/compute.jar -Djava.rmi.server.hostname=localhost -Djava.security.polic y=c:\home\ann\policy\server.policy engine.ComputeEngine ComputeEngine bound
However, when i try to run client i got exceptions
access: access allowed (java.lang.RuntimePermission createClassLoader) access: access allowed (java.lang.reflect.ReflectPermission suppressAccessChecks ) access: access allowed (java.lang.reflect.ReflectPermission suppressAccessChecks ) access: access allowed (java.lang.reflect.ReflectPermission suppressAccessChecks ) access: access allowed (java.lang.reflect.ReflectPermission suppressAccessChecks ) ComputePi exception: java.rmi.ServerException: RemoteException occurred in server thread; nested exce ption is: java.rmi.UnmarshalException: error unmarshalling arguments; nested excep tion is: java.lang.ClassNotFoundException: access to class loader denied at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source) at sun.rmi.transport.Transport$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Unknown Source) at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Sou rce) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Sour ce) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source ) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknow n Source) at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source) at sun.rmi.server.UnicastRef.invoke(Unknown Source) at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unkn own Source) at java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source) at $Proxy0.executeTask(Unknown Source) at client.ComputePi.main(ComputePi.java:27) Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested ex ception is: java.lang.ClassNotFoundException: access to class loader denied at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source) at sun.rmi.transport.Transport$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Unknown Source) at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Sou rce) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Sour ce) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source ) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: access to class loader denied at sun.rmi.server.LoaderHandler.loadClass(Unknown Source) at sun.rmi.server.LoaderHandler.loadClass(Unknown Source) at java.rmi.server.RMIClassLoader$2.loadClass(Unknown Source) at java.rmi.server.RMIClassLoader.loadClass(Unknown Source) at sun.rmi.server.MarshalInputStream.resolveClass(Unknown Source) at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source) at java.io.ObjectInputStream.readClassDesc(Unknown Source) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at sun.rmi.server.UnicastRef.unmarshalValue(Unknown Source) ... 10 more Caused by: java.security.AccessControlException: access denied (java.io.FilePerm ission \c:\home\jones\public_html\classes\- read) at java.security.AccessControlContext.checkPermission(Unknown Source) at java.security.AccessController.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPermission(Unknown Source) at sun.rmi.server.LoaderHandler$Loader.checkPermissions(Unknown Source) at sun.rmi.server.LoaderHandler$Loader.access$000(Unknown Source) ... 21 more
i believe the problem is the client policy file for client (correct if i am wrong please), as we can see from stack trace
Caused by: java.security.AccessControlException: access denied (java.io.FilePerm ission \c:\home\jones\public_html\classes\- read)
However, my client.policy file looks like
grant codeBase "file:/c:/home/jones/public_html/classes/-" { permission java.security.AllPermission; }; grant{ permission java.net.SocketPermission "127.0.0.1:1024-65535", "connect,resolve"; };
There are AllPermission for codeBase "file:/c:/home/jones/public_html/classes/-".
So, did i set the codeBase permission wrong, so there are more permission client application needs?
Thanks!!!
Update:
if i move the client.policy file to C:\Program Files\Java\jre6\lib\security and
i start the client with
C:\Documents and Settings\jianzhang>java -cp c:\home\jones\src;c:\home\jones\pub lic_html\classes\compute.jar -Djava.rmi.server.codebase=file:/c:/home/jones/publ ic_html/classes/ -Djava.security.policy=client.policy -Djava.security.debug=acce ss,failure client.ComputePi localhost 45
i got exception
ComputePi exception: java.security.AccessControlException: access denied (java.net.SocketPermission 1 27.0.0.1:1099 connect,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.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.(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.lookup(Unknown Source) at client.ComputePi.main(ComputePi.java:25)
However, the client.policy file has specified
grant{ permission java.net.SocketPermission "127.0.0.1:1024-65535", "connect,resolve"; };
Update with full stack trace
Here is the full stack trace,
C:\home\jones\src>java -cp C:\home\jones\src;C:\home\jones\public_html\classes\c ompute.jar;C:\home\jones\public_html\classes -Djava.rmi.server.codebase=file:/C: /home/jones/public_html/classes/ -Djava.security.policy=client.policy -Djava.sec urity.debug=access,failure client.ComputePi localhost 45 access: access allowed (java.lang.reflect.ReflectPermission suppressAccessChecks ) access: access allowed (java.security.SecurityPermission getProperty.policy.expa ndProperties) access: access allowed (java.security.SecurityPermission getProperty.policy.igno reIdentityScope) access: access allowed (java.security.SecurityPermission getProperty.policy.allo wSystemProperty) access: access allowed (java.util.PropertyPermission sun.security.policy.utf8 re ad) access: access allowed (java.util.PropertyPermission sun.security.policy.numcach es read) access: access allowed (java.util.PropertyPermission java.security.policy read) access: access allowed (java.util.PropertyPermission user.dir read) access: access allowed (java.io.FilePermission C:\home\jones\src\client.policy r ead) access: access allowed (java.io.FilePermission client.policy read) access: access allowed (java.security.SecurityPermission getProperty.policy.url. 1) access: access allowed (java.util.PropertyPermission java.home read) access: access allowed (java.io.FilePermission C:\Program Files\Java\jre6\lib\se curity\java.policy read) access: access allowed (java.io.FilePermission C:\Program Files\Java\jre6\lib\se curity\java.policy read) access: access allowed (java.io.FilePermission C:\Program Files\Java\jre6\lib\se curity\java.policy read) access: access allowed (java.io.FilePermission C:\Program Files\Java\jre6\lib\se curity\java.policy read) access: access allowed (java.util.PropertyPermission java.ext.dirs read) access: access allowed (java.io.FilePermission C:\Program Files\Java\jre6\lib\ex t\* read) access: access allowed (java.io.FilePermission C:\WINDOWS\Sun\Java\lib\ext\* rea d) access: access allowed (java.security.SecurityPermission getProperty.policy.url. 2) access: access allowed (java.util.PropertyPermission user.home read) access: access allowed (java.io.FilePermission C:\Documents and Settings\anga ng\.java.policy read) access: access allowed (java.io.FilePermission C:\Documents and Settings\anga ng\.java.policy read) access: access allowed (java.io.FilePermission C:\Documents and Settings\anga ng\.java.policy read) access: access allowed (java.security.SecurityPermission getProperty.policy.url. 3) access: access allowed (java.util.PropertyPermission java.security.auth.policy r ead) access: access allowed (java.security.SecurityPermission getProperty.auth.policy .url.1) access: access allowed (java.lang.RuntimePermission accessClassInPackage.sun.sec urity.provider) access: access allowed (java.lang.reflect.ReflectPermission suppressAccessChecks ) access: access allowed (java.util.PropertyPermission java.security.egd read) access: access allowed (java.security.SecurityPermission getProperty.securerando m.source) access: access allowed (java.security.SecurityPermission putProviderProperty.SUN ) access: access allowed (java.lang.reflect.ReflectPermission suppressAccessChecks ) access: access allowed (java.lang.reflect.ReflectPermission suppressAccessChecks ) access: access allowed (java.util.PropertyPermission * read,write) access: access allowed (java.util.PropertyPermission os.arch read) access: access allowed (java.util.PropertyPermission java.net.preferIPv6Addresse s read) access: access allowed (java.lang.RuntimePermission loadLibrary.net) access: access allowed (java.io.FilePermission C:\Program Files\Java\jre6\bin\ne t.dll read) access: access allowed (java.util.PropertyPermission java.net.preferIPv4Stack re ad) access: access allowed (java.util.PropertyPermission impl.prefix read) access: access allowed (java.lang.reflect.ReflectPermission suppressAccessChecks ) access: access allowed (java.util.PropertyPermission sun.net.spi.nameservice.pro vider.1 read) access: access allowed (java.net.SocketPermission myComputer resolve) access: access allowed (java.security.SecurityPermission getProperty.networkaddr ess.cache.ttl) access: access allowed (java.util.PropertyPermission sun.net.inetaddr.ttl read) access: access allowed (java.security.SecurityPermission getProperty.networkaddr ess.cache.negative.ttl) access: access allowed (java.io.FilePermission C:\Documents and Settings\anga ng\Local Settings\Temp read) access: access allowed (java.io.FilePermission C:\Documents and Settings\anga ng\Local Settings\Temp read) access: access allowed (java.io.FilePermission C:\Documents and Settings\anga ng\Local Settings\Temp read) access: access allowed (java.io.FilePermission C:\Documents and Settings\anga ng\Local Settings\Temp read) access: access allowed (java.io.FilePermission C:\DOCUME~1\ang~1\LOCALS~1\Tem p read) access: access allowed (java.util.PropertyPermission java.rmi.server.hostname re ad) access: access allowed (java.io.FilePermission C:\home\jones\src read) access: access denied (java.net.SocketPermission myComputer resolve) java.lang.Exception: Stack trace at java.lang.Thread.dumpStack(Unknown Source) 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.getLocalHost(Unknown Source) at sun.rmi.transport.tcp.TCPEndpoint.(Unknown Source) at java.rmi.registry.LocateRegistry.getRegistry(Unknown Source) at java.rmi.registry.LocateRegistry.getRegistry(Unknown Source) at java.rmi.registry.LocateRegistry.getRegistry(Unknown Source) at client.ComputePi.main(ComputePi.java:24) access: access allowed (java.security.SecurityPermission getPolicy) access: access allowed (java.io.FilePermission C:\home\jones\src read) access: domain that failed ProtectionDomain (file:/C:/home/jones/src/ ) sun.misc.Launcher$AppClassLoader@1b90b39 java.security.Permissions@d70d7a ( (java.lang.RuntimePermission stopThread) (java.lang.RuntimePermission exitVM) (java.io.FilePermission \C:\home\jones\src\- read) (java.util.PropertyPermission line.separator read) (java.util.PropertyPermission java.vm.version read) (java.util.PropertyPermission java.vm.specification.version read) (java.util.PropertyPermission java.vm.specification.vendor read) (java.util.PropertyPermission java.vendor.url read) (java.util.PropertyPermission java.vm.name read) (java.util.PropertyPermission os.name read) (java.util.PropertyPermission java.vm.vendor read) (java.util.PropertyPermission path.separator read) (java.util.PropertyPermission java.specification.name read) (java.util.PropertyPermission os.version read) (java.util.PropertyPermission os.arch read) (java.util.PropertyPermission java.class.version read) (java.util.PropertyPermission java.version read) (java.util.PropertyPermission file.separator read) (java.util.PropertyPermission java.vendor read) (java.util.PropertyPermission java.vm.specification.name read) (java.util.PropertyPermission java.specification.version read) (java.util.PropertyPermission java.specification.vendor read) (java.net.SocketPermission localhost:1024- listen,resolve) ) access: access allowed (java.util.PropertyPermission java.rmi.server.useLocalHos tName read) access: access allowed (java.util.PropertyPermission sun.rmi.transport.logLevel read) access: access allowed (java.util.PropertyPermission sun.rmi.log.useOld read) access: access allowed (java.util.PropertyPermission java.util.logging.manager r ead) access: access allowed (java.lang.RuntimePermission setContextClassLoader) access: access allowed (java.lang.RuntimePermission shutdownHooks) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.PropertyPermission java.util.logging.config.cl ass read) access: access allowed (java.util.PropertyPermission java.util.logging.config.fi le read) access: access allowed (java.util.PropertyPermission java.home read) access: access allowed (java.io.FilePermission C:\Program Files\Java\jre6\lib\lo gging.properties read) access: access allowed (java.io.FilePermission C:\Program Files\Java\jre6\lib\lo gging.properties read) access: access allowed (java.io.FilePermission C:\Program Files\Java\jre6\lib\lo gging.properties read) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.PropertyPermission line.separator read) access: access allowed (java.util.PropertyPermission line.separator read) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.PropertyPermission sun.rmi.transport.tcp.logLe vel read) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.PropertyPermission sun.rmi.transport.tcp.maxCo nnectionThreads read) access: access allowed (java.util.PropertyPermission sun.rmi.transport.tcp.threa dKeepAliveTime read) access: access allowed (java.util.PropertyPermission sun.rmi.transport.proxy.log Level read) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.PropertyPermission sun.rmi.transport.proxy.con nectTimeout read) access: access allowed (java.util.PropertyPermission sun.rmi.transport.proxy.eag erHttpFallback read) access: access allowed (java.util.PropertyPermission http.proxyHost read) access: access allowed (java.util.PropertyPermission proxyHost read) access: access allowed (java.util.PropertyPermission java.rmi.server.disableHttp read) access: access allowed (java.util.PropertyPermission sun.rmi.transport.tcp.readT imeout read) access: access allowed (java.util.PropertyPermission sun.rmi.server.logLevel rea d) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.PropertyPermission java.rmi.server.ignoreStubC lasses read) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.PropertyPermission sun.rmi.client.logCalls rea d) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.PropertyPermission java.rmi.server.hostname re ad) access: access allowed (java.util.PropertyPermission sun.rmi.transport.connectio nTimeout read) access: access allowed (java.util.PropertyPermission sun.rmi.transport.tcp.hands hakeTimeout read) access: access allowed (java.util.PropertyPermission sun.rmi.transport.tcp.respo nseTimeout read) access: access allowed (java.util.logging.LoggingPermission control) access: access allowed (java.util.PropertyPermission sun.rmi.runtime.schedulerTh reads read) access: access allowed (java.lang.RuntimePermission sun.rmi.runtime.RuntimeUtil. getInstance) access: access allowed (java.net.SocketPermission localhost resolve) access: access allowed (java.lang.RuntimePermission loadLibrary.net) access: access allowed (java.io.FilePermission C:\Program Files\Java\jre6\bin\ne t.dll read) access: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve) java.lang.Exception: Stack trace at java.lang.Thread.dumpStack(Unknown Source) 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.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.(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.lookup(Unknown Source) at client.ComputePi.main(ComputePi.java:25) access: access allowed (java.security.SecurityPermission getPolicy) access: access allowed (java.io.FilePermission C:\home\jones\src read) access: domain that failed ProtectionDomain (file:/C:/home/jones/src/ ) sun.misc.Launcher$AppClassLoader@1b90b39 java.security.Permissions@77158a ( (java.lang.RuntimePermission stopThread) (java.lang.RuntimePermission exitVM) (java.io.FilePermission \C:\home\jones\src\- read) (java.util.PropertyPermission line.separator read) (java.util.PropertyPermission java.vm.version read) (java.util.PropertyPermission java.vm.specification.version read) (java.util.PropertyPermission java.vm.specification.vendor read) (java.util.PropertyPermission java.vendor.url read) (java.util.PropertyPermission java.vm.name read) (java.util.PropertyPermission os.name read) (java.util.PropertyPermission java.vm.vendor read) (java.util.PropertyPermission path.separator read) (java.util.PropertyPermission java.specification.name read) (java.util.PropertyPermission os.version read) (java.util.PropertyPermission os.arch read) (java.util.PropertyPermission java.class.version read) (java.util.PropertyPermission java.version read) (java.util.PropertyPermission file.separator read) (java.util.PropertyPermission java.vendor read) (java.util.PropertyPermission java.vm.specification.name read) (java.util.PropertyPermission java.specification.version read) (java.util.PropertyPermission java.specification.vendor read) (java.net.SocketPermission localhost:1024- listen,resolve) ) ComputePi exception: java.security.AccessControlException: access denied (java.net.SocketPermission 1 27.0.0.1:1099 connect,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.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.(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.lookup(Unknown Source) at client.ComputePi.main(ComputePi.java:25)
At line 80:
access: access allowed (java.net.SocketPermission myComputer resolve)
however afrom line 99 to 111
access: access denied (java.net.SocketPermission myComputer resolve) java.lang.Exception: Stack trace at java.lang.Thread.dumpStack(Unknown Source) 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.getLocalHost(Unknown Source) at sun.rmi.transport.tcp.TCPEndpoint.(Unknown Source) at java.rmi.registry.LocateRegistry.getRegistry(Unknown Source) at java.rmi.registry.LocateRegistry.getRegistry(Unknown Source) at java.rmi.registry.LocateRegistry.getRegistry(Unknown Source) at client.ComputePi.main(ComputePi.java:24)
Problem solved, see
my another post
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你如何启动客户端?启动客户端时是否指定策略文件?
启动客户端的命令行应如下所示:
更新:您写道:
您需要将示例中看到的路径(
c:\home\jones
等)更改为您在计算机上使用的实际路径。机器(您的代码库和安全文件所在的位置)。How do you start the client? Do you specify a policy file when starting the client?
Your command line to start the client should look like:
Update: you wrote:
You need to change the paths you see in the examples (
c:\home\jones
, etc.) to the actual ones you use on your machine (where your code base and security files are).