Hi Michael:
I just found out I had a copy of "The Complete
Java 2 Certification Study Guide", which was co-authered by you and two other person. Firstly I want to say that is a terrific book, the only book I read to pass the programmer exam.
I also got another book "Java 2 developer handbook", which were written by the two person who are the co-auther of the book I mentioned earlier along with you. I read some pages regarding RMI. There is a program which doesn't compile. The program is List 12.6. I was wondering if you can point out what is wrong with it. I attached this program by the end of this message. I guess this may be a small error. The error message I got is as below.
Thanks in advance for the help!
Don
Error message
---------------------------------------
CardBank: create a CreditManager
CardBank: bind it to a name
java.security.AccessControlException: access denied (java.net.SocketPermission 1
27.0.0.1:1099 connect,resolve)
at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:272)
at java.security.AccessController.checkPermission(AccessController.java:
399)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1044)
at java.net.Socket.<init>(Socket.java:262)
at java.net.Socket.<init>(Socket.java:100)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirect
SocketFactory.java:25)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMaster
SocketFactory.java:120)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:499)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:190
)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:174)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:318)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:160)
at CardBank.main(CardBank.java:20)
access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve)
--------------------------------------------------------
The program LIST 12.6
---------------------------------------------------------
import credit.*;
import java.util.*;
import java.rmi.*;
public class CardBank {
public static void main (
String args[]) {
// Create and install a security manager.
System.setSecurityManager(new RMISecurityManager());
try {
// Create an instance of our Credit Manager.
System.out.println("CardBank: create a CreditManager");
CreditManagerImpl cmi = new CreditManagerImpl();
// Bind the object instance to the remote registry. Use the
// static rebind() method to avoid conflicts.
System.out.println("CardBank: bind it to a name");
Naming.rebind("cardManager", cmi);
System.out.println("CreditManager is now ready");
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
}
}