tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amit shah <amits...@gmail.com>
Subject Re: JDBC Pool - Error handling during connection creation
Date Wed, 07 Mar 2012 05:12:47 GMT
Comments below.

Thanks,
Amit.

On Tue, Mar 6, 2012 at 8:07 PM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Amit,
>
> On 3/6/12 4:46 AM, amit shah wrote:
> > Hello, I am using the tomcat jdbc pool independently in my
> > application and frequently I faced a NullPointerException with the
> > below stack trace
> >
> > null at
> >
> org.apache.tomcat.jdbc.pool.ConnectionPool.setupConnection(ConnectionPool.java:276)
>
> What
> >
> exact version of Tomcat and/or the Tomcat pool are you using?
>

I am using tomcat-jdbc.jar and tomcat-juli.jar from version 7.0.26.

>
> > The root cause of the exception is suppressed by the jdbc pool code
> > by returning null from the validate() method. My point of raising
> > this up is that it becomes hard to troubleshoot such errors in
> > production when the actual exception is suppressed. The actual
> > exception occurs while executing the initSQL query or the
> > validation query.
> >
> > Shouldn't an exception be thrown right at the point where the
> > error occurred?
>
> I don't see any place in setupConnection where an exception is
> swallowed, do you?
>
>
> http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java?view=markup


Have a look at the public boolean validate(int validateAction,String sql)
method in PooledConnection class line no - 445. The validate method ignores
any exception which is thrown while validating the connection or executing
the initSQL query.
The createConnection() method in ConnectionPool class which calls the
validate() method returns null in such a case and hence it leads to a null
pointer exception in setupConnection method.

Ignoring the exception in the validate() method may sound appropriate (not
sure for what reason though) but my point is that it makes troubleshooting
the issue a lot harder.


>
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk9WIS4ACgkQ9CaO5/Lv0PAyFACfe/0jqpUzA1krhuxTFb/4sxJQ
> 46oAoJXV48dwC6IFy4f1dozhOc45Wo3R
> =ZHQa
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message