wood burning stoves 2.0*
The moose likes Distributed Java and the fly likes not able to run the sample program of rmi in oracle rmi trails ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "not able to run the sample program of rmi in oracle rmi trails ?" Watch "not able to run the sample program of rmi in oracle rmi trails ?" New topic
Author

not able to run the sample program of rmi in oracle rmi trails ?

gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

when i try to run the example given in the rmi trails of oracle java tutorial given at http://docs.oracle.com/javase/tutorial/rmi/running.html. i get the following exception while running the server program

C:\Users\gurpreet>java -cp D:\home\ann\src;D:\home\ann\public_html\classes\compu
te.jar -Djava.rmi.server.codebase=file:/D:/home/ann/public_html/classes/compute.
jar -Djava.rmi.server.hostname=mycomputer.example.com -Djava.security.policy="F:
\server.policy" engine.ComputeEngine
ComputeEngine exception:
java.security.AccessControlException: access denied ("java.net.SocketPermission"
"127.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.<init>(Unknown Source)
at java.net.Socket.<init>(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.rebind(Unknown Source)
at engine.ComputeEngine.main(ComputeEngine.java:34)

uptil now i have compiled all the source files as mentioned in the tutorial. then i started the registry.when i tried to start the server program which in the tutorial is ComputeEngine it gives above exception. please help

Edward Harned
Ranch Hand

Joined: Sep 19, 2005
Posts: 291

You need to have a policy file with RMI, such as:

and on your script add: -Djava.security.policy=%WHERE YOU PUT IT%\Security\policy.all


Ed's latest article: A Java Parallel Calamity http://coopsoft.com/ar/Calamity2Article.html
gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

Edward Harned wrote:You need to have a policy file with RMI, such as:

and on your script add: -Djava.security.policy=%WHERE YOU PUT IT%\Security\policy.all


thanks for the reply Edward but i'm getting exact same error. i even turned my firewall off still same exception stack trace
Edward Harned
Ranch Hand

Joined: Sep 19, 2005
Posts: 291

You have a permission problem. The "all" permission policy works for ALL permissions. So java isn't finding your policy file. When java doesn't find a policy file it never says so, it just craps out. Look further into finding the file.
gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

hi Edward

Following are the policy files i'm using and the command used to invoke the server

Edward Harned
Ranch Hand

Joined: Sep 19, 2005
Posts: 291

Try using the file I gave you with: permission java.security.AllPermission "", "";

The RMI Registry is a Java program and also needs a permission file.
brwon jett
Greenhorn

Joined: Jan 15, 2013
Posts: 1
uptil now i have compiled all the source files as mentioned in the tutorial. then i started the registry.when i tried to start the server program which in the tutorial is ComputeEngine it gives above exception. please help


brown
gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

hi brwon jett. i thought it is me who is getting the same exception. i guess there is some error in the tutorial or some piece of code needs to be alighend/changed. until now i tried many things. what i gathered so far is that the problem is in the policy files. i tried different thigns but without in vain. still waiting for someone who actualy ran that code or who can help us solve this problem.
Edward Harned
Ranch Hand

Joined: Sep 19, 2005
Posts: 291

I've been doing RMI since release 1.1. I gave you a policy file that works. Use it. Other people have been using the tutorial for over a decade. Perhaps the problem is not with the tutorial.
gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

Edward Harned wrote:I've been doing RMI since release 1.1. I gave you a policy file that works. Use it. Other people have been using the tutorial for over a decade. Perhaps the problem is not with the tutorial.


no offence Edward but if everything in the tutorial is correct you wouldn't have given me the policy files. anyways as I told earlier I used the policy files which you gave me and getting the same exception. also because of some reason i'm not able to come back to the problem and solve it. I will try to research and post here after 19th feb(I have OCEWCD 6 exam that day)

meanwhile I think brown jett can post his code here and you can help him out
 
jQuery in Action, 2nd edition
 
subject: not able to run the sample program of rmi in oracle rmi trails ?