aspose file tools*
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
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "RMI example code fails" Watch "RMI example code fails" New topic
Author

RMI example code fails

NJ Ban
Greenhorn

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-",
"connect,accept";
permission java.net.SocketPermission "*:80",
"connect";
};
5. Run the server code.
set classpath=D:\TIEJ1.1\Code\rmiex
java -Djava.rmi.server.codebase=file// :/TIEJ1.1/Code/rmiex
-Djava.rmi.server.hostname=localhost
-Djava.security.policy=".\java2.policy"
engine.ComputeEngine
6. Now i get SocketPermission error.
ComputeEngine exception: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve)
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 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
Greenhorn

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

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