Advertisement
|
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.
Message:
RMI server sample code of "Thinking in JAVA"
Posted by Robert Ding on July 27, 2000 at 12:01 PM
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 java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve) at java.lang.Throwable.fillInStackTrace(Native Method) at java.lang.Throwable.(Throwable.java:94) at java.lang.Exception.(Exception.java:42) at java.lang.RuntimeException.(RuntimeException.java:47) at java.lang.SecurityException.(SecurityException.java:39) at java.security.AccessControlException.(AccessControlException.java:57) at java.security.AccessControlContext.checkPermission(Compiled Code) at java.security.AccessController.checkPermission(Compiled Code) at java.lang.SecurityManager.checkPermission(Compiled Code) at java.lang.SecurityManager.checkConnect(SecurityManager.java:1021) at java.net.Socket.(Socket.java:258) at java.net.Socket.(Socket.java:98) at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:29) at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Compiled Code) at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:497) at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:194) at sun.rmi.transport.tcp.TCPChannel.newConnection(Compiled Code) at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322) at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source) at java.rmi.Naming.rebind(Naming.java:165) at PerfectTime.main(PerfectTime.java:19)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(); } } }
Replies:
|