Here's the code which appears to be relevant, with some commentary on what happens when it is run. Large portions of (hopefully) irrelevant code have been snipped.
Client:
COMMENT: Start a server using RMI. This appears to
COMMENT: succeed, since a message printed by this
COMMENT: server does appear.
try {
DistLrnRemoteData dlrd =
(DistLrnRemoteData)Naming.lookup(
"//"+personHost+
"/DistanceLearningData");
dlrd.activatePersonServer();// Get server going
}
catch (Exception e) {
System.err.println(e);
COMMENT: This line is NOT printed, so apparently
COMMENT: there is no Exception.
System.err.println("Unable to initialize remote Person server");
e.printStackTrace(System.err);
}
Person result = new Person();
int count = 10;
boolean opened = false;
Socket gpsocket = null;
while (!opened) {
try {
COMMENT: The client attempts to open the socket
COMMENT: here. The server never seems to accept it,
COMMENT: but this call appears to succeed. There is
COMMENT: no Exception. The server is running code
COMMENT: from the class RemoteDataServer, so the
COMMENT: port should be the same. The testing was
COMMENT: done with a single host acting as both
COMMENT: client and server, so there isn't any firewall
COMMENT: or network outage problem.
gpsocket = new Socket(personHost,
RemoteDataServer.personReadPort);
opened = true;
}
catch (IOException ioe) {
count--;
if (count <= 0) {
COMMENT: This line is NOT printed, so apparently there
COMMENT: is no IOException when the Socket is
COMMENT: created. Nor does an UnknownHostException
COMMENT: or SecurityException stop the program.
System.err.println(ioe);
ioe.printStackTrace(System.err);
result = null;
return result;
}
try {
Thread.sleep(1000);
}
catch (InterruptedException ie) {
System.err.println(ie);
ie.printStackTrace(System.err);
}
}
}
// Read the serialized object
try {
COMMENT: No problem with the next line, which attempts
COMMENT: to access the OutputStream of the socket.
MyStringWriter msw = new MyStringWriter(
gpsocket.getOutputStream());
COMMENT: The next line causes the message.
ObjectInputStream ois =
new ObjectInputStream(gpsocket.getInputStream());
msw.write(personRealName);
// Now read the resulting Person.
try {
result = (Person)(ois.readObject());
}
catch (ClassNotFoundException cnfe) {
System.err.println(cnfe);
cnfe.printStackTrace(System.err);
System.exit(4);
}
}
catch (IOException ioe) {
System.err.println(ioe);
ioe.printStackTrace(System.err);
result = null;
}
Server:
public void activateFocusServer() throws java.rmi.RemoteException {
String [] cmd = new String[2];
cmd[0] = new String("java");
cmd[1] = new String("RemoteDataServer");
try {
COMMENT: FORTE's Output window shows a message
COMMENT: from this process
Process dbserver =
Runtime.getRuntime().exec(cmd); // Server will self-destruct
// after a timeout period
}
catch (IOException ioe) {
COMMENT: This message is never printed
System.err.println(ioe);
ioe.printStackTrace(System.err);
}
}
RemoteDataServer:
public RemoteDataServer() {
try {
...many different servers started here...
ServerSocket PersonReadSocket = new ServerSocket(personReadPort);
PersonReadListener prl = new PersonReadListener(PersonReadSocket);
prl.start();
....
catch (IOException ioe) {
COMMENT: This message is never printed.
System.err.println(ioe);
ioe.printStackTrace(System.err);
}
COMMENT: PersonReadListener is an inner class:
class PersonReadListener extends java.lang.Thread {
private Thread BaseThread;
private ServerSocket theSocket;
/** Creates an object to listen for PersonRead requests
* @param ss The server socket to listen with
*/
public PersonReadListener(ServerSocket ss) {
theSocket = ss;
}
/** Initializes the thread to listen for PersonRead requests
*/
public void start() {
BaseThread = new Thread(this);
BaseThread.start();
}
/** The code for the server to listen for PersonRead requests
*/
public void run() {
while(true) {
try {
COMMENT: This code doesn't have access to System.err
COMMENT: so a file is created to print debugging output
PrintWriter debug = new PrintWriter(new FileWriter("person.debug"));
COMMENT: The next line IS printed, so the server gets
COMMENT: this far.
debug.println("Waiting for connection for person's name");
debug.close();
PersonReadClientConnection someone =
new PersonReadClientConnection(theSocket.accept());
COMMENT: If the previous "debug.close" line is
COMMENT: commented out and the next two lines are
COMMENT: uncommented, the next line is NOT
COMMENT: printed, so apparently the accept nevers
COMMENT: happens! Why does the accept fail, but
COMMENT: the client's socket creation succeed?
// debug.println("Accepted a connection");
// debug.close();
someone.start();
}
catch (IOException ioe) {
COMMENT: These lines are NOT printed
System.err.println(ioe);
ioe.printStackTrace(System.err);
}