File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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\
String name = "//localhost/Compute";
2. Then compiled this code.
set classpath=D:\TIEJ1.1\Code\rmiex
javac engine\
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 "*:1024-",
permission "*: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 ( connect,resolve) access denied ( connect,resolve)
at Source)
at Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at Source)
at Source)
at<init>(Unknown Source)
at<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(
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 "*: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?
It is sorta covered in the JavaRanch Style Guide.
subject: RMI example code fails