• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

A Question for Mr. Michael Ernest

Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!

Error message
CardBank: create a CreditManager
CardBank: bind it to a name
java.security.AccessControlException: access denied (java.net.SocketPermission 1 connect,resolve)
at java.security.AccessControlContext.checkPermission(AccessControlConte
at java.security.AccessController.checkPermission(AccessController.java:
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
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMaster
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 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) {
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again Don -
Thank you for the kind words on the RHE book.
So you have the Developer Handbook? I'm sure Simon and Phil would be pleased to hear that.
The only downside to writing a Developer Handbook is that so many things seem to change in Java from JDK to JDK. It's hard to stay current; but I think I can help here. For starters, change your security manager to a regular (new SecurityManager()) if you're using JDK 1.2.2 or later. There's no longer a need to fool with RMISecurityManager or similar subclasses.
Next it looks like you may not have the rmiregistry tool running on your system. The telltale sign is the resolve, connect complaint at port 1099, which is rmiregistry's default service port.
rmiregistry uses a classloader to register remote objects, so it needs to see the stub and remote interface classes. You can cheat for the moment by putting those classes in rmiregistry's classpath. You know about the java.rmi.server.codebase property and how to use it? And to get the client to work, you'll need to set up a policy file, but I trust the DH covers that.
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks again!
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic