Everytime I try to connect with the server via RMI I get stuck in
catch().
try
{
GarageServerImpl g = new GarageServerImpl();
Naming.rebind("Serve", g); // sets the handle
System.out.println("GarageServer started and " +
"awaiting connections.");
}
catch (RemoteException er)
{
System.out.println(
"Exception in GarageServer.main: " + er);
}
catch (Exception err)
{
System.out.println(
"Exception occurred: " + err);
}
}
Help? I don't know how to fix...
Oliver Wong - 16 Aug 2006 22:07 GMT
> Everytime I try to connect with the server via RMI I get stuck in
> catch().
[quoted text clipped - 19 lines]
>
> Help? I don't know how to fix...
If you're just going to display the exception, don't catch it at all.
Instead, throw it all the way up, and the JVM will eventually catch and
display the exception for you, with more detailed information (such as a
stack trace).
Once you have the stack trace, post it here. See
http://riters.com/JINX/index.cgi/Suggestions_20for_20Asking_20Questions_20on_20N
ewsgroups#RepeatErrorsExactly
- Oliver
Eric Sosman - 16 Aug 2006 22:07 GMT
Nancy.Nicole@gmail.com wrote On 08/16/06 16:47,:
> Everytime I try to connect with the server via RMI I get stuck in
> catch().
[quoted text clipped - 19 lines]
>
> Help? I don't know how to fix...
I don't know what's wrong, but here's a suggestion: Each
of those Exception objects carries a lot of information about
the exact nature of the error and where it occurred -- and
you're throwing most of it away. (And you've kept what little
remains hidden from the rest of us ...)
Discard those System.out.println() calls and use the
Exception objects' printStackTrace() methods instead, and
you're likely to learn lots more about the circumstances
of the problem.

Signature
Eric.Sosman@sun.com
Thomas Fritsch - 17 Aug 2006 00:06 GMT
> Everytime I try to connect with the server via RMI I get stuck in
> catch().
[quoted text clipped - 19 lines]
>
> Help? I don't know how to fix...
You can declare your main method with a throws-clause:
public static void main(String args[]) throws Exception
{
GarageServerImpl g = new GarageServerImpl();
Naming.rebind("Serve", g); // sets the handle
System.out.println("GarageServer started and " +
"awaiting connections.");
}
This has two advantages: You don't need any try/catch at all,
and in case of exception the JVM will print the stack trace.

Signature
Thomas
Nancy.Nicole@gmail.com - 17 Aug 2006 13:41 GMT
> You can declare your main method with a throws-clause:
>
[quoted text clipped - 11 lines]
> --
> Thomas
Okay, here's the problem with that:
All of this happens when the user clicks "Submit", which means
actionPerformed calls my getQuote() method which is what uses the
try{}catch(){}. actionPerformed cannot throw an exception (or so that
is what the command prompt declares).
I can't think of another way to get around it. Ideas?
Oliver Wong - 17 Aug 2006 15:18 GMT
>> You can declare your main method with a throws-clause:
>>
[quoted text clipped - 20 lines]
>
> I can't think of another way to get around it. Ideas?
For debugging purposes, catch and rethrow as an error. E.g.
public yourMethod() {
try {
/*whatever*/
} catch (NameOfTheException e) {
throw new Error(e);
}
}
Once you find out more information about the exception, you can figure
out how to handle it properly, in which case you'd replace the "throw new
Error(e)" code with code that actually handles the error.
- Oliver
Nancy.Nicole@gmail.com - 17 Aug 2006 16:36 GMT
> Once you find out more information about the exception, you can figure
> out how to handle it properly, in which case you'd replace the "throw new
> Error(e)" code with code that actually handles the error.
>
> - Oliver
Okay, sorry, the server I'm using is secure and I was trying a port
that had not yet been set to forward to the server. Obviously I don't
know anything about netwoking. Thanks for all the help, guys!