Tomcat DBCP Logging

2013-03-06 Thread Rahul Somasunderam
Hi,

I'm running Tomcat 7.0.23. I've got a question about configuring the logging of 
DBCP Failures. 

I've go this in my context xml file.

Context docBase=/home/foo/war/ path=/foo reloadable=true
   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
   /
/Context

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.
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 logging.properties to make tomcat log this?

R,
rahul

smime.p7s
Description: S/MIME cryptographic signature


Re: Tomcat DBCP Logging

2013-03-06 Thread Daniel Mikusa
On Mar 6, 2013, at 1:49 PM, Rahul Somasunderam wrote:

 Hi,
 
 I'm running Tomcat 7.0.23.

This is getting pretty old, you might want to consider upgrading.

 I've got a question about configuring the logging of DBCP Failures. 
 
 I've go this in my context xml file.
 
 Context docBase=/home/foo/war/ path=/foo reloadable=true
   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
   /
 /Context
 
 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.

When it's wrong what happens?  How are you testing for failure?  Are you 
accessing a page in your app that requires the DB?

 I suppose Tomcat/DBCP is catching the exception and not logging it.

Hard to say for sure, but it's possible that DBCP may not even be connecting to 
the Database.  The initialSize parameter defaults to 0, so on startup it 
won't make any connections.  Maybe try setting initialSize to 1 and see 
what happens.

  https://commons.apache.org/dbcp/configuration.html

Dan

 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 logging.properties to make tomcat log this?
 
 R,
 rahul

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Tomcat DBCP Logging

2013-03-06 Thread Rahul Somasunderam

On Mar 6, 2013, at 11:26 AM, Daniel Mikusa dmik...@vmware.com wrote:

 On Mar 6, 2013, at 1:49 PM, Rahul Somasunderam wrote:
 
 Hi,
 
 I'm running Tomcat 7.0.23.
 
 This is getting pretty old, you might want to consider upgrading.

I will, but I don't think this has to do much with tomcat being old. I think 
it's with me having to configure the logging correctly.

 
 I've got a question about configuring the logging of DBCP Failures. 
 
 I've go this in my context xml file.
 
 Context docBase=/home/foo/war/ path=/foo reloadable=true
  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
  /
 /Context
 
 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.
 
 When it's wrong what happens?  How are you testing for failure?  Are you 
 accessing a page in your app that requires the DB?

I'm testing this by changing the password in my context to be a wrong password. 
I'm looking at the startup logs and I see this in catalina.out

Mar 06, 2013 11:57:27 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Mar 06, 2013 11:57:27 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/foo] startup failed due to previous errors

And this in localhost.date.log

Mar 06, 2013 10:13:17 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Mar 06, 2013 10:13:17 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Mar 06, 2013 10:13:17 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: 
attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 
'org.apache.jasper.compiler.TldLocationsCache@1296dee6')
Mar 06, 2013 11:56:55 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Mar 06, 2013 11:58:57 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Mar 06, 2013 11:58:57 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Mar 06, 2013 11:58:57 AM org.apache.catalina.core.ApplicationContext log


 
 I suppose Tomcat/DBCP is catching the exception and not logging it.
 
 Hard to say for sure, but it's possible that DBCP may not even be connecting 
 to the Database.  The initialSize parameter defaults to 0, so on startup it 
 won't make any connections.  Maybe try setting initialSize to 1 and see 
 what happens.
 
  https://commons.apache.org/dbcp/configuration.html
 
 Dan
 
 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 logging.properties to make tomcat log this?
 
 R,
 rahul
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org
 



smime.p7s
Description: S/MIME cryptographic signature


Re: Tomcat DBCP Logging

2013-03-06 Thread Daniel Mikusa
On Mar 6, 2013, at 5:07 PM, Rahul Somasunderam wrote:

 
 On Mar 6, 2013, at 11:26 AM, Daniel Mikusa dmik...@vmware.com wrote:
 
 On Mar 6, 2013, at 1:49 PM, Rahul Somasunderam wrote:
 
 Hi,
 
 I'm running Tomcat 7.0.23.
 
 This is getting pretty old, you might want to consider upgrading.
 
 I will, but I don't think this has to do much with tomcat being old. I think 
 it's with me having to configure the logging correctly.

You're right, this is not related to the issue at hand.  It's just a general 
reminder :)

 
 
 I've got a question about configuring the logging of DBCP Failures. 
 
 I've go this in my context xml file.
 
 Context docBase=/home/foo/war/ path=/foo reloadable=true
 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
 /
 /Context
 
 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.
 
 When it's wrong what happens?  How are you testing for failure?  Are you 
 accessing a page in your app that requires the DB?
 
 I'm testing this by changing the password in my context to be a wrong 
 password. I'm looking at the startup logs and I see this in catalina.out
 
 Mar 06, 2013 11:57:27 AM org.apache.catalina.core.StandardContext 
 startInternal
 SEVERE: Error listenerStart
 Mar 06, 2013 11:57:27 AM org.apache.catalina.core.StandardContext 
 startInternal
 SEVERE: Context [/foo] startup failed due to previous errors

Your application failed to start for some reason.  It appears that a listener 
has failed.  You should check the other Tomcat log files and your application 
log files for clues.

 
 And this in localhost.date.log
 
 Mar 06, 2013 10:13:17 AM org.apache.catalina.core.ApplicationContext log
 INFO: ContextListener: contextInitialized()
 Mar 06, 2013 10:13:17 AM org.apache.catalina.core.ApplicationContext log
 INFO: SessionListener: contextInitialized()
 Mar 06, 2013 10:13:17 AM org.apache.catalina.core.ApplicationContext log
 INFO: ContextListener: 
 attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 
 'org.apache.jasper.compiler.TldLocationsCache@1296dee6')
 Mar 06, 2013 11:56:55 AM org.apache.catalina.core.ApplicationContext log
 INFO: Initializing Spring root WebApplicationContext
 Mar 06, 2013 11:58:57 AM org.apache.catalina.core.ApplicationContext log
 INFO: ContextListener: contextInitialized()
 Mar 06, 2013 11:58:57 AM org.apache.catalina.core.ApplicationContext log
 INFO: SessionListener: contextInitialized()
 Mar 06, 2013 11:58:57 AM org.apache.catalina.core.ApplicationContext log

Is this the entire localhost.-MM-DD.log file?  Given the SEVERE log in 
catalina.out, I would have expected an exception here.

Dan

PS.  Have you tried setting the initialSize attribute on your Resource / 
tag?  That should force DBCP to create a connection at startup and, if that 
connection fails, it should log it.  I tested this in my Tomcat setup, with an 
out-of-the-box logging configuration, and it worked fine.


 
 
 I suppose Tomcat/DBCP is catching the exception and not logging it.
 
 Hard to say for sure, but it's possible that DBCP may not even be connecting 
 to the Database.  The initialSize parameter defaults to 0, so on startup 
 it won't make any connections.  Maybe try setting initialSize to 1 and 
 see what happens.
 
 https://commons.apache.org/dbcp/configuration.html
 
 Dan
 
 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 logging.properties to make tomcat log this?
 
 R,
 rahul
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org
 
 

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Tomcat DBCP Logging

2013-03-06 Thread Rahul Somasunderam
Thanks Dan,

The initialSize brought the logs into my catalina.out.

R,
rahul

On Mar 6, 2013, at 2:21 PM, Daniel Mikusa dmik...@vmware.com wrote:

 On Mar 6, 2013, at 5:07 PM, Rahul Somasunderam wrote:
 
 
 On Mar 6, 2013, at 11:26 AM, Daniel Mikusa dmik...@vmware.com wrote:
 
 On Mar 6, 2013, at 1:49 PM, Rahul Somasunderam wrote:
 
 Hi,
 
 I'm running Tomcat 7.0.23.
 
 This is getting pretty old, you might want to consider upgrading.
 
 I will, but I don't think this has to do much with tomcat being old. I think 
 it's with me having to configure the logging correctly.
 
 You're right, this is not related to the issue at hand.  It's just a general 
 reminder :)
 
 
 
 I've got a question about configuring the logging of DBCP Failures. 
 
 I've go this in my context xml file.
 
 Context docBase=/home/foo/war/ path=/foo reloadable=true
 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
 /
 /Context
 
 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.
 
 When it's wrong what happens?  How are you testing for failure?  Are you 
 accessing a page in your app that requires the DB?
 
 I'm testing this by changing the password in my context to be a wrong 
 password. I'm looking at the startup logs and I see this in catalina.out
 
 Mar 06, 2013 11:57:27 AM org.apache.catalina.core.StandardContext 
 startInternal
 SEVERE: Error listenerStart
 Mar 06, 2013 11:57:27 AM org.apache.catalina.core.StandardContext 
 startInternal
 SEVERE: Context [/foo] startup failed due to previous errors
 
 Your application failed to start for some reason.  It appears that a listener 
 has failed.  You should check the other Tomcat log files and your application 
 log files for clues.
 
 
 And this in localhost.date.log
 
 Mar 06, 2013 10:13:17 AM org.apache.catalina.core.ApplicationContext log
 INFO: ContextListener: contextInitialized()
 Mar 06, 2013 10:13:17 AM org.apache.catalina.core.ApplicationContext log
 INFO: SessionListener: contextInitialized()
 Mar 06, 2013 10:13:17 AM org.apache.catalina.core.ApplicationContext log
 INFO: ContextListener: 
 attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 
 'org.apache.jasper.compiler.TldLocationsCache@1296dee6')
 Mar 06, 2013 11:56:55 AM org.apache.catalina.core.ApplicationContext log
 INFO: Initializing Spring root WebApplicationContext
 Mar 06, 2013 11:58:57 AM org.apache.catalina.core.ApplicationContext log
 INFO: ContextListener: contextInitialized()
 Mar 06, 2013 11:58:57 AM org.apache.catalina.core.ApplicationContext log
 INFO: SessionListener: contextInitialized()
 Mar 06, 2013 11:58:57 AM org.apache.catalina.core.ApplicationContext log
 
 Is this the entire localhost.-MM-DD.log file?  Given the SEVERE log in 
 catalina.out, I would have expected an exception here.
 
 Dan
 
 PS.  Have you tried setting the initialSize attribute on your Resource / 
 tag?  That should force DBCP to create a connection at startup and, if that 
 connection fails, it should log it.  I tested this in my Tomcat setup, with 
 an out-of-the-box logging configuration, and it worked fine.
 
 
 
 
 I suppose Tomcat/DBCP is catching the exception and not logging it.
 
 Hard to say for sure, but it's possible that DBCP may not even be 
 connecting to the Database.  The initialSize parameter defaults to 0, so 
 on startup it won't make any connections.  Maybe try setting initialSize 
 to 1 and see what happens.
 
 https://commons.apache.org/dbcp/configuration.html
 
 Dan
 
 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 logging.properties to make tomcat log this?
 
 R,
 rahul
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org
 
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org
 



smime.p7s
Description: S/MIME cryptographic signature


Re: Tomcat DBCP Logging

2013-03-06 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Rahul,

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
IOException.

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 logging.properties 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
-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlE4IWkACgkQ9CaO5/Lv0PBAHACgkklRQ3gHYFuYrahND3bOtW8C
xsYAn0yw1zEGnQkNV3JxCaR48TrJOjHO
=8CKa
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org