tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Tomcat DBCP Logging
Date Thu, 07 Mar 2013 05:11:05 GMT
Hash: SHA256


On 3/6/13 12:49 PM, Rahul Somasunderam wrote:
> I'm running Tomcat 7.0.23. I've got a question about configuring
> the logging of DBCP Failures.

Echoing Daniel's suggestion: upgrade.

> I've go this in my context xml file.
> <Context docBase="/home/foo/war/" path="/foo" reloadable="true">

The "path" attribute is illegal, here: remove it.

> <Resource name="jdbc/hd/datasource" auth="Container" 
> type="javax.sql.DataSource" 
> driverClassName="oracle.jdbc.OracleDriver" 
> url="jdbc:oracle:thin:@//localhost:1531/PROD" username="foouser" 
> password="foopass" />

<Resource> looks good: you confirm that it works properly when
username/password are correct.

> When the username and password are correct, I have no trouble 
> connecting and my application works as expected. However when this
> is wrong, I get no indication of why it went wrong. I suppose
> Tomcat/DBCP is catching the exception and not logging it.

Nope: Tomcat/DBCP does not catch any of these exceptions. If I change
my username/password to incorrect ones, I get an exception for each
connection attempt. My application code catches the exception and logs
it appropriately.

If you fetch the connection in a JSP and don't have any catch blocks,
the JSP compiler adds try/catch for you and re-throws the exception as
a ServletException -- servlet can only throw ServletException and

If you use some framework (Spring, Struts, etc.) with a
front-controller, they can all be configured with their own error
handlers: perhaps you have poorly-configured one of these components.

If you wrote your own servlet, then you should read your own code
because you are probably catching and swallowing these exceptions.

How do you fetch a connection from the pool?

> When I try from outside of tomcat using jdbc, I see Oracle
> returning a ORA-01017 error code and jdbc throwing an exception.
> What must I do in the to make tomcat log this?

AFAIK, nothing: Tomcat should log any uncaught exception. Do you get a
Tomcat 500 response page with a stack trace? If not, some other
component (under /your/ control) is handling the exception - and not
the way you want it to.

- -chris
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools -
Comment: Using GnuPG with Thunderbird -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message