My first RMI program my permission problem

KABOOM
KABOOM used Ask the Experts™
on
I'm writing my very first RMI program and the problem occurs when I run the server.  I get an error saying:
java.net.SocketPermission 127.0.0.1:1099 connect, resolve

How do I fix this?  I read that one possible problem could be the way my computer at home is set up.  I've read some stuff about setting the classpath variable on Windows machines but i'm pretty sure that's not the problem because i've run non-RMI projects on this machine without problems.
I'm running Win2k with Java 2 1.4.x

Here's my code:

import java.rmi.*;
import java.rmi.server.*;

public class SimpleServer extends UnicastRemoteObject implements ServerInterface
{     int matrix1[] = {1, 2, 3, 4, 5};
     int matrix2[] = {6, 7, 8, 9, 10};
     private String ServerName;
     
     SimpleServer(String name) throws RemoteException
     {     super();    
          this.ServerName = name;
     }
     
     public int add() throws RemoteException
     {     System.out.println("Call to add works");
          return 0;
     }

     public int multiply() throws RemoteException
     {     System.out.println("Call to mult works");
          return 0;
     }
     
     public static void main(String args[])
     {     RMISecurityManager SecMgr = new RMISecurityManager();
          System.setSecurityManager(SecMgr);
          try
          {
               SimpleServer myServer = new SimpleServer("FirstRMIServer");
               Naming.rebind("rmi://localhost/FirstRMIServer", myServer);
               System.out.println("RMI Server is registered");
          }
          catch(Exception e)
          {     System.out.println("ERROR: " + e.getMessage());          }    
     }
}
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
have u set up a policy file where u are granting all permissions liek for example..

grant {
        permission java.security.AllPermission;
     permission java.net.SocketPermission "127.0.0.1:1024-", "accept, connect, listen, resolve";};
     
vemul

Commented:
check out this site and the SUN RMI site too.. it's got to do with the security file

http://patriot.net/~tvalesky/easyrmi.html

vemul
Mick BarryJava Developer
Top Expert 2010

Commented:
Do you specify your security policy when you start up the server?
This describes running an RMI server:
http://java.sun.com/docs/books/tutorial/rmi/running.html

Author

Commented:
Ok, I read all the articles and tried the security file specified by the link that vemul provided.  The problem is the client says "permission denied" when i've given the AllPermission command in my security policy file.  I thought I might have not closed my server down properly hence I would have two servers listening on the same port but I even went as far as rebooting the machine to make sure but that didn't seem to fix it.

Are there other suggestions?
Later,
KABOOM
Mick BarryJava Developer
Top Expert 2010

Commented:
can u show us how u start your server, and the contents of your policy file.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial