• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

A Question for Mr. Michael Ernest

 
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
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());
}
}
}
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks again!
Don
 
I don't even know how to spell CIA. But this tiny ad does:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic