You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Rob Johnson <ro...@rsjohnson.fsnet.co.uk> on 2001/10/31 00:11:56 UTC

Tomcat 4.0.1 doing odd Exception handling

I'm having an interesting problem with Tomcat 4.0.1:

I run this line of code from within a servlet:

try {
    System.out.println("1");
    Classloader.getSystemClassLoader().loadClass(classname);
    System.out.println("2");
} catch (Exception e) {
    System.out.println("Executing catch block");
} finally {
    System.out.println("Executing finally block");
}

The Classloader line of code causes some sort of error because '2' is never
printed out, but the catch block isn't executed either - execution jumps
straight to the
finally block. I can't find anything unusual in the logs.  Can anyone help?

The test code works fine with Tomcat 3.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tomcat 4.0.1 doing odd Exception handling

Posted by Dmitri Colebatch <di...@bigpond.net.au>.
If an Error is thrown, the catch (Exception) wont catch it.  If all you
want to do is find out what is going on, then you could change the catch
(Exception) to catch (Throwable) and you should see something.  *warning*
this is about the only thing worse than catch (Exception) imho, so dont
leave it in your code once your figured it out (o:

cheers
dim

On Tue, 30 Oct 2001, Rob Johnson wrote:

> I'm having an interesting problem with Tomcat 4.0.1:
> 
> I run this line of code from within a servlet:
> 
> try {
>     System.out.println("1");
>     Classloader.getSystemClassLoader().loadClass(classname);
>     System.out.println("2");
> } catch (Exception e) {
>     System.out.println("Executing catch block");
> } finally {
>     System.out.println("Executing finally block");
> }
> 
> The Classloader line of code causes some sort of error because '2' is never
> printed out, but the catch block isn't executed either - execution jumps
> straight to the
> finally block. I can't find anything unusual in the logs.  Can anyone help?
> 
> The test code works fine with Tomcat 3.
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>