You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Bill Schneider <bs...@vecna.com> on 2002/12/07 23:18:23 UTC
NullPointerException from incorrect JDBCRealm setup
Hi,
I used Realms for the first time today with Tomcat 4.0.6. I noticed that,
if you don't specify the "userCredCol" attribute correctly with the
JDBCRealm (for example, accidentally calling it "userCredColumn"), you end
up with a not-too-descriptive NullPointerException. (JDBCRealm line 389 in
Tomcat 4.0.6.)
Tracking this down in the source, it appears that if you don't specify the
userCredCol attribute, the following SQL query results:
SELECT null FROM user_table WHERE username_column = ?
This is a valid query and won't throw a SQLException. If the user exists,
the query returns a row, but with "null" instead of the password. The call
to "rs.getString(1).trim()" then throws the NullPointerException.
It would be useful for JDBCRealm to instead throw an exception sooner if
either of the critical parameters are not set properly. This would enable
a more useful error message to be logged.
-- Bill
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: NullPointerException from incorrect JDBCRealm setup
Posted by "Craig R. McClanahan" <cr...@apache.org>.
To avoid it getting lost in mail folders, could you please submit a bug
report for this?
http://nagoya.apache.org/bugzilla/
Thanks!
Craig
On Sat, 7 Dec 2002, Bill Schneider wrote:
> Date: Sat, 07 Dec 2002 17:18:23 -0500
> From: Bill Schneider <bs...@vecna.com>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: tomcat-user@jakarta.apache.org
> Subject: NullPointerException from incorrect JDBCRealm setup
>
> Hi,
>
> I used Realms for the first time today with Tomcat 4.0.6. I noticed that,
> if you don't specify the "userCredCol" attribute correctly with the
> JDBCRealm (for example, accidentally calling it "userCredColumn"), you end
> up with a not-too-descriptive NullPointerException. (JDBCRealm line 389 in
> Tomcat 4.0.6.)
>
> Tracking this down in the source, it appears that if you don't specify the
> userCredCol attribute, the following SQL query results:
>
> SELECT null FROM user_table WHERE username_column = ?
>
> This is a valid query and won't throw a SQLException. If the user exists,
> the query returns a row, but with "null" instead of the password. The call
> to "rs.getString(1).trim()" then throws the NullPointerException.
>
> It would be useful for JDBCRealm to instead throw an exception sooner if
> either of the critical parameters are not set properly. This would enable
> a more useful error message to be logged.
>
> -- Bill
>
>
> --
> 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>