The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
July 2000



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


Running RMI

Posted by Robert on July 30, 2001 at 8:44 AM

Hi Rob,

If you want to just test the RMI code and see how it functions then you have to comment on the following inside public static void main() and do the usual stuff of compiling and creating stubs and skeletons.
// System.setSecurityManager(new RMISecurityManager());

This should help you in understanding the basics about RMI.
To run with the above said code you need to change the policy file. Run the policy tool in the bin directory to grant permissions to the files.

Have a nice time coding ..


> I've tried to compile and run the RMI sample code of "Thinking in Java" ebook. But I always got exceptions while running server,
> here is the exception traces, anybody can tell me, what's wrong with that.

> Thanks
> Robert

> access denied ( connect,resolve)
> at java.lang.Throwable.fillInStackTrace(Native Method)
> at java.lang.Throwable.(
> at java.lang.Exception.(
> at java.lang.RuntimeException.(
> at java.lang.SecurityException.(
> at
> at Code)
> at Code)
> at java.lang.SecurityManager.checkPermission(Compiled Code)
> at java.lang.SecurityManager.checkConnect(
> at
> at
> at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(
> at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Compiled Code)
> at sun.rmi.transport.tcp.TCPEndpoint.newSocket(
> at sun.rmi.transport.tcp.TCPChannel.createConnection(
> at sun.rmi.transport.tcp.TCPChannel.newConnection(Compiled Code)
> at sun.rmi.server.UnicastRef.newCall(
> at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
> at java.rmi.Naming.rebind(
> at PerfectTime.main(

> The server code is:
> public class PerfectTime extends UnicastRemoteObject implements PerfectTimeI{
> public long getPerfectTime() throws RemoteException{
> return System.currentTimeMillis();
> }
> public PerfectTime() throws RemoteException{
> super();
> }

> public static void main(String[] args){
> System.setSecurityManager(new RMISecurityManager());
> try{
> PerfectTime pt = new PerfectTime();
> Naming.rebind("PerfectTime", pt);
> System.out.println("Object registered!");
> }catch(Exception e){
> e.printStackTrace();
> }
> }
> }


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us