Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exceptions Handling and Stack Traces in JDK 1.1.8 1

Status
Not open for further replies.

JavaCowboy

Programmer
Aug 16, 2001
2
CA
Hi,

I'm presently maintain and upgrading a Web-Objects 4.5 application that uses the JDK 1.18. There are two constantly recurring exceptions that keep getting thrown, exceptions for which there are no stack traces. These are exceptions thrown by methods that do not presently have throws or try/catch code associated with them.

My questions are:

1) Why are there no stack traces available? Is it because the exception handling code is not there, or could there be another reason?

2) Will the inclusion of exception-handling code ALWAYS lead to stack traces and messages becoming available (if I put a e.printStackTrace() in my catch(Excetion e) clause), or will there be situations where it will not be available?

3) What is the best way for me to handle these types of exceptions in order to gain the most information possible about their root causes and possible solutions?

Thanks for your help.
 
Sorry, looks like this thread is being ignored.

As far as I know (and I am answering this in the hope that someone will contradict me and therefore provide you with some better feedback).

I was under the impression that you would get a stack trace if your method included a 'throws' clause in the definition. However, in my short amount of experience, the compiler will not allow you to compile a method that may potentially throw an exception without you including the throws clause and/or a try/catch in your code. So I always get a stack trace when my apps screw up. Although it should be said that I am using 1.2.1 and not 1.1.8, so I cannot help you interms of that. Maybe, this is a new check put into the java compiler.

The purpose of a try/catch is so that normal processing can continue after an exception has been thrown - otherwise the application will abend. I would definitely recommend you code some try/catch statements with a e.printStackTrace line put in. This should always print out the cause of the error (in a roundabout way).

Definitely the best way to handle exceptions is to include the code that may throw them in a try/catch - other wise everytime you get an exception your program will abend. If you have a try catch at least the application can continue, it is all about graceful degradation, the user would probably much rather the application continued with reduced functionality than just stopping abruptly on the first problem encountered.
Sorry I can't be of more help, but hey, maybe someone else will take a look now and add their tuppence (sorry, I'm a Brit, I should have said 'two cents').
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top