wood burning stoves*
The moose likes Distributed Java and the fly likes RMI example code fails Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "RMI example code fails" Watch "RMI example code fails" New topic

RMI example code fails

NJ Ban

Joined: Oct 17, 2003
Posts: 2
I was running Sun's sample RMI code and it still gives me a problem. I looked up many helps on-line and I think I did everything correctly but I am still facing problem. Please help.
1. First everthing is under D:\TIEJ1.1\Code\rmiex and the service name is given as following in engine\ComputeEngine.java
String name = "//localhost/Compute";
2. Then compiled this code.
set classpath=D:\TIEJ1.1\Code\rmiex
javac engine\ComputeEngine.java
rmic -d . engine.ComputeEngine
3. So there are three classes in engine directory, ComputeEngine.class, ComputeEngine_Stub.class and ComputeEngine_Skel.class.
4. java2.policy file is set like this in D:\TIEJ1.1\Code\rmiex.
grant codebase "file://D:/TIEJ1.1/Code/rmiex/*" {
permission java.net.SocketPermission "*:1024-",
permission java.net.SocketPermission "*:80",
5. Run the server code.
set classpath=D:\TIEJ1.1\Code\rmiex
java -Djava.rmi.server.codebase=file// :/TIEJ1.1/Code/rmiex
6. Now i get SocketPermission error.
ComputeEngine exception: access denied (java.net.SocketPermission connect,resolve)
java.security.AccessControlException: access denied (java.net.SocketPermission 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 Source)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source)
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 java.rmi.Naming.rebind(Unknown Source)
at engine.ComputeEngine.main(ComputeEngine.java:27)
Most of the people who saw the same error seemed to solve the problem by fixing policy file but I cannot do that. I don't know why. The only thing that I could think of was Norton firewall. So I tried the same thing turning on and off Norton but it doesn't make any difference. Does anyone have a clue? Please help me on this.
Michael Conley

Joined: Oct 14, 2003
Posts: 3
Try this in the policy file:
permission java.net.SocketPermission "*:1099", "connect,resolve";
You need resolve.
Good luck,
NJ Ban

Joined: Oct 17, 2003
Posts: 2
Mike, I tried but it doesn't make any difference. I still get the same error. Is there any known software conflicts?
I agree. Here's the link: http://aspose.com/file-tools
subject: RMI example code fails