RMI tutorial - got "acceenied" exception

From: Jun (junchien888_at_hotmail.com)
Date: 10/30/03


Date: 30 Oct 2003 01:42:20 -0800

I tried the Sun's RMI example at

http://java.sun.com/docs/books/tutorial/rmi/index.html

The server run fine with commandline

cd deployment\classes
java -classpath ".\deployment;%CLASSPATH%;"
-Djava.rmi.server.codebase=file:/c:\My_test\rmi2\deployment\classes/
-Djava.rmi.server.hostname=12.236.86.90
-Djava.security.policy=..\java.policy engine.ComputeEngine

and java.policy file as

grant {
    permission java.net.SocketPermission "*:1024-65535",
        "connect,accept";
    permission java.io.FilePermission
        "c:\\My_test\\rmi2\\deployment\\classes\\-", "read";
};

I got the exception below when trying the client with commandline

cd client_dir
java -classpath ".;compute.jar;%CLASSPATH%"
-Djava.rmi.server.codebase=file:/c:\my_test\rmi2\client_dir/
-Djava.security.policy=client.policy client.ComputePi 12.236.86.90 20

with client.policy as

grant {
    permission java.net.SocketPermission "*:1024-65535",
        "connect,accept";
    permission java.io.FilePermission
        "C:\\My_test\\rmi2\\client_dir\\-", "read";

};

I noticed that it complained the permission

"(java.io.FilePermission \c:\My_test\rmi2\deployment\classes\- read)"

which is the codebase used by the server. As you can see that
this permission is already in the java.policy used by server.

Any point about what is wrong?

thanks

============== exception when run client, ComputePi ===============

C:\My_test\rmi2\client_dir>java -classpath
".;compute.jar;.;C:\j2sdk\jre\lib
jar;C:\my_db\oracle\ora92\jdbc\lib\classes111.zip;C:\my_db\oracle\ora92\jdbc
\nls_charset11;C:\my_db\oracle\ora92\jdbc\lib\ojdbc14.jar;C:\j2sdk\lib\tools
;C:\My_try\JClass50K\lib\jcjarmasterK.jar;C:\My_try\JClass50K;C:\My_enterpri
oap-2_2/soap.jar;C:\My_enterprise\javamail-1.2\mail.jar;C:\My_enterprise\jaf
.1\activation.jar;C:\My_enterprise\soap-2_2;C:\My_enterprise\bsf-2_2\lib\bsf
;C:\My_enterprise\rhino1_5R2\js.jar"
-Djava.rmi.server.codebase=file:/c:\my_
\rmi2\client_dir/ -Djava.security.policy=client.policy
client.ComputePi 12.
86.90 20
ComputePi exception: error unmarshalling return; nested exception is:
        java.lang.ClassNotFoundException: access denied to class
loader
java.rmi.UnmarshalException: error unmarshalling return; nested
exception is
        java.lang.ClassNotFoundException: access denied to class
loader
java.lang.ClassNotFoundException:
java.security.AccessControlException: acce
enied (java.io.FilePermission \c:\My_test\rmi2\deployment\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
Sour
        at sun.rmi.server.LoaderHandler$Loader.access$000(Unknown
Source)
        at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
        at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
        at sun.rmi.server.MarshalInputStream.resolveClass(Unknown
Source)
        at java.io.ObjectInputStream.inputClassDescriptor(Unknown
Source)
        at java.io.ObjectInputStream.readObject(Unknown Source)
        at java.io.ObjectInputStream.readObject(Unknown Source)
        at java.io.ObjectInputStream.inputObject(Unknown Source)
        at java.io.ObjectInputStream.readObject(Unknown Source)
        at java.io.ObjectInputStream.readObject(Unknown Source)
        at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
        at java.rmi.Naming.lookup(Unknown Source)
        at client.ComputePi.main(ComputePi.java:15)



Relevant Pages

  • Re: JAVA works C# not !!!!!!!
    ... The server is the same nothing changed, I have no server codes, it is ... works on JAVA. ... I don't know where I need to check permissions and if it is for write ... permission why throw this kind of exception? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: BufferedReader.readLine() hangs
    ... experience with Java, and I inherited the code that originally called ... I changed my test code to eliminate calls to ready, ... public static boolean getRowthrows Exception ... it only occurs with the server VM, so far as I can tell. ...
    (comp.lang.java.help)
  • Re: RMI & connection refused
    ... java -Djava.security.policy=policy RMIServer localhost 1099 & ... the client machine, telnet to port 1099 on the server machine. ... server thread; nested exception is: ...
    (comp.lang.java.programmer)
  • JAVA RMI register problem
    ... Im making aplication with Java RMI ... ... Today i started to run server and i cant make it:((once ... d exception is: ...
    (comp.lang.java.programmer)
  • RE: Backup & Monitoring not working!
    ... Error message in Windows Small Business Server 2003: ... Microsoft CSS Online Newsgroup Support ... This newsgroup only focuses on SBS technical issues. ... An unhandled exception occurred during the execution of the ...
    (microsoft.public.windows.server.sbs)