You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by DIGLLOYD INC <di...@diglloyd.com> on 2008/09/01 17:33:58 UTC

JDBCRealm.getRoles causes NullPointerException

I'm running Tomcat 6.0.16 with DIGEST auth using:

MySQL 5.0.51b + mysql-connector-java-5.1.6-bin.jar

Things work well until complete failure: every few days, all  
authentication begins to fail.  When this happens, nothing appears in  
catalina.out to indicate a problem, and unless I restart Tomcat, no  
authentication ever succeeds again.  It begins working immediately  
after Tomcat is restarted.  I've never had to restart MySQL for 2  
months.

The only clue I see in catalina.out is the stack trace below (10 of  
them or so), about 9 hours *prior* to my detecting the authentication  
failure.  However, my access logs show that users logged in  
successfully *after* that series of failures.

I'm not sure where or how to debug this further.  It seems that Tomcat  
is making a bad call to next() which causes the NPE, but that's  
unclear; perhaps it's ResultSetImpl with a problem.  It's also unclear  
why there's a burst of such problems, then no further ones in the log,  
then the hours-later complete failure.

Aug 31, 2008 5:30:48 PM org.apache.catalina.connector.CoyoteAdapter  
service
SEVERE: An exception or error occurred in the container during the  
request processing
java.lang.NullPointerException
	at  
com.mysql.jdbc.ResultSetImpl.setRowPositionValidity(ResultSetImpl.java: 
826)
	at com.mysql.jdbc.ResultSetImpl.next(ResultSetImpl.java:7046)
	at org.apache.catalina.realm.JDBCRealm.getRoles(JDBCRealm.java:632)
	at org.apache.catalina.realm.JDBCRealm.getPrincipal(JDBCRealm.java:596)
	at org.apache.catalina.realm.RealmBase.authenticate(RealmBase.java:400)
	at  
org 
.apache 
.catalina 
.authenticator 
.DigestAuthenticator.findPrincipal(DigestAuthenticator.java:283)
	at  
org 
.apache 
.catalina 
.authenticator 
.DigestAuthenticator.authenticate(DigestAuthenticator.java:176)
	at  
org 
.apache 
.catalina 
.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:491)
	at com.diglloyd.tomcat.BadInputValve.invoke(BadInputValve.java:284)
	at  
org 
.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java: 
128)
	at  
org 
.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java: 
102)
	at  
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java: 
568)
	at  
org 
.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java: 
394)
	at  
org 
.apache 
.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at  
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java: 
286)
	at  
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java: 
844)
	at org.apache.coyote.http11.Http11Protocol 
$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java: 
447)
	at java.lang.Thread.run(Thread.java:613)


Lloyd Chambers
http://diglloyd.com

[Mac OS X 10.5.2 Intel, Tomcat 6.0.16]





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: JDBCRealm.getRoles causes NullPointerException

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mark,

Mark Thomas wrote:
> Christopher Schultz wrote:
>> Right: JDBCRealm does not do any connection pooling AFAIK.
> 
> It is better than that. It uses a single connection and lots of syncs :)

Sweet! Sounds like a heckuva first-term freshman hack-job to me.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkjQJOIACgkQ9CaO5/Lv0PAqOQCggHTR48qmxyWM2zcNXvRckVXi
CboAn0MhjoLCSlxsI0xSBfwglg8rCS6P
=eOpr
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: JDBCRealm.getRoles causes NullPointerException

Posted by Mark Thomas <ma...@apache.org>.
Christopher Schultz wrote:
> Lloyd,
> 
> DIGLLOYD INC wrote:
>> I am using  <Realm className="org.apache.catalina.realm.JDBCRealm" ... >
> 
>> I don't know what's required to use a DataSourceRealm (yet), but if it's
>> a simple switch I'll try it.
> 
> 
> Ooh, using DataSourceRealm is much better, because you can share the
> JDBC Connection objects with the rest of your application. It apparently
> also doesn't suffer from this bug. If you are already using a DataSource
> in your application, just switch the className and then remove all the
> connection information from your <Realm> and replace it with the
> required DataSource name (see the docs for specifics).
> 
>> I am not sharing anything; the database is used for authentication
>> only.  I've declared the realm, but I don't think there's any pool
>> involved.
> 
> Right: JDBCRealm does not do any connection pooling AFAIK.

It is better than that. It uses a single connection and lots of syncs :)

Mark


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: JDBCRealm.getRoles causes NullPointerException

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lloyd,

DIGLLOYD INC wrote:
> I am using  <Realm className="org.apache.catalina.realm.JDBCRealm" ... >
> 
> I don't know what's required to use a DataSourceRealm (yet), but if it's
> a simple switch I'll try it.


Ooh, using DataSourceRealm is much better, because you can share the
JDBC Connection objects with the rest of your application. It apparently
also doesn't suffer from this bug. If you are already using a DataSource
in your application, just switch the className and then remove all the
connection information from your <Realm> and replace it with the
required DataSource name (see the docs for specifics).

> I am not sharing anything; the database is used for authentication
> only.  I've declared the realm, but I don't think there's any pool
> involved.

Right: JDBCRealm does not do any connection pooling AFAIK.

> I don't know how to set up a "validation query" or "debugging options
> for leaked connections".  I see the problem occur just after restarting
> tomcat so leaked connections shouldn't be the problem.

For the DataSourceRealm, you can simply set these options on your
<Resource> that defines the DataSource. You just set the validationQuery
attribute to something that your database is guaranteed to execute
successfully. MySQL users often choose "SELECT 1" but pretty much
anything will work.

> The odd thing is that it has run for 10 days, then it just fails, and
> then fails after restarting Tomcat.  That makes it really hard to
> isolate the cause.

Agreed: very strange.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkjQHmEACgkQ9CaO5/Lv0PAHVACbBK8J1sFObfNYKMJmPBCLdnG7
JlYAn1nEp8JRGjSrSZgpFW8t8hw7D8Z4
=I6hD
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: JDBCRealm.getRoles causes NullPointerException

Posted by DIGLLOYD INC <di...@diglloyd.com>.
Thank you Chris.

Mark suggested it was probably:  https://issues.apache.org/bugzilla/show_bug.cgi?id=45453

I am using  <Realm className="org.apache.catalina.realm.JDBCRealm" ... >

I don't know what's required to use a DataSourceRealm (yet), but if  
it's a simple switch I'll try it.

I am not sharing anything; the database is used for authentication  
only.  I've declared the realm, but I don't think there's any pool  
involved.

I don't know how to set up a "validation query" or "debugging options  
for leaked connections".  I see the problem occur just after  
restarting tomcat so leaked connections shouldn't be the problem.

The odd thing is that it has run for 10 days, then it just fails, and  
then fails after restarting Tomcat.  That makes it really hard to  
isolate the cause.


Lloyd

Lloyd Chambers
http://diglloyd.com

[Mac OS X 10.5.2 Intel, Tomcat 6.0.16]




On Sep 3, 2008, at 9:39 AM, Christopher Schultz wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Lloyd,
>
> DIGLLOYD INC wrote:
>> MySQL 5.0.51b + mysql-connector-java-5.1.6-bin.jar
>
> Have you tried downgrading to a 5.0 version? It might be worth it to  
> see
> if there is some weird problem with their new driver.
>
>> The only clue I see in catalina.out is the stack trace below (10 of  
>> them
>> or so), about 9 hours *prior* to my detecting the authentication
>> failure.  However, my access logs show that users logged in  
>> successfully
>> *after* that series of failures.
>
> That indicates to me that you are using multiple connections to the
> database, and perhaps one of them gets damaged but the others are  
> okay.
> Do you see any other JDBC-related exceptions on your logs, or any  
> faults
> detected on the MySQL-server-side?
>
> Are you using a DataSourceRealm? If so, are you sharing that  
> DataSource
> with your actual application, or do you have a separate one for
> authentication?
>
> Any other problems /not/ related to authentication?
>
> Do you have a validationQuery set for your JDBC/JNDI <Resource>? If  
> so,
> what is it? Also, do you have the debugging options for leaked
> connections turned on?
>
>> I'm not sure where or how to debug this further.  It seems that  
>> Tomcat
>> is making a bad call to next() which causes the NPE, but that's  
>> unclear;
>> perhaps it's ResultSetImpl with a problem.  It's also unclear why
>> there's a burst of such problems, then no further ones in the log,  
>> then
>> the hours-later complete failure.
>
> I suspect that your connection pool is slowly failing, one  
> connection at
> a time. When you run out of useful connections, your app is dead.
>
>> Aug 31, 2008 5:30:48 PM org.apache.catalina.connector.CoyoteAdapter  
>> service
>> SEVERE: An exception or error occurred in the container during the
>> request processing
>> java.lang.NullPointerException
>>    at
>> com 
>> .mysql.jdbc.ResultSetImpl.setRowPositionValidity(ResultSetImpl.java: 
>> 826)
>>    at com.mysql.jdbc.ResultSetImpl.next(ResultSetImpl.java:7046)
>>    at org.apache.catalina.realm.JDBCRealm.getRoles(JDBCRealm.java: 
>> 632)
>
> I would check with MySQL as well. I've found that my reported bugs  
> never
> get fixed, but sometimes Tonci will at least get back to you ;)
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAki+vd0ACgkQ9CaO5/Lv0PCa8QCeMoMC4hYDVZnK2TM+If/sJ7wC
> YTYAnjHrmxXSu2rLdE5i2YDirOtAh3tb
> =+9Cz
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: JDBCRealm.getRoles causes NullPointerException

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lloyd,

DIGLLOYD INC wrote:
> MySQL 5.0.51b + mysql-connector-java-5.1.6-bin.jar

Have you tried downgrading to a 5.0 version? It might be worth it to see
if there is some weird problem with their new driver.

> The only clue I see in catalina.out is the stack trace below (10 of them
> or so), about 9 hours *prior* to my detecting the authentication
> failure.  However, my access logs show that users logged in successfully
> *after* that series of failures.

That indicates to me that you are using multiple connections to the
database, and perhaps one of them gets damaged but the others are okay.
Do you see any other JDBC-related exceptions on your logs, or any faults
detected on the MySQL-server-side?

Are you using a DataSourceRealm? If so, are you sharing that DataSource
with your actual application, or do you have a separate one for
authentication?

Any other problems /not/ related to authentication?

Do you have a validationQuery set for your JDBC/JNDI <Resource>? If so,
what is it? Also, do you have the debugging options for leaked
connections turned on?

> I'm not sure where or how to debug this further.  It seems that Tomcat
> is making a bad call to next() which causes the NPE, but that's unclear;
> perhaps it's ResultSetImpl with a problem.  It's also unclear why
> there's a burst of such problems, then no further ones in the log, then
> the hours-later complete failure.

I suspect that your connection pool is slowly failing, one connection at
a time. When you run out of useful connections, your app is dead.

> Aug 31, 2008 5:30:48 PM org.apache.catalina.connector.CoyoteAdapter service
> SEVERE: An exception or error occurred in the container during the
> request processing
> java.lang.NullPointerException
>     at
> com.mysql.jdbc.ResultSetImpl.setRowPositionValidity(ResultSetImpl.java:826)
>     at com.mysql.jdbc.ResultSetImpl.next(ResultSetImpl.java:7046)
>     at org.apache.catalina.realm.JDBCRealm.getRoles(JDBCRealm.java:632)

I would check with MySQL as well. I've found that my reported bugs never
get fixed, but sometimes Tonci will at least get back to you ;)

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAki+vd0ACgkQ9CaO5/Lv0PCa8QCeMoMC4hYDVZnK2TM+If/sJ7wC
YTYAnjHrmxXSu2rLdE5i2YDirOtAh3tb
=+9Cz
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: JDBCRealm.getRoles causes NullPointerException

Posted by DIGLLOYD INC <di...@diglloyd.com>.
Thank you Mark, I will look into this bug. and also DataSourceRealm.


Lloyd Chambers
http://diglloyd.com

[Mac OS X 10.5.2 Intel, Tomcat 6.0.16]




On Sep 3, 2008, at 10:31 AM, Mark Thomas wrote:

> DIGLLOYD INC wrote:
>> Aug 31, 2008 5:30:48 PM org.apache.catalina.connector.CoyoteAdapter  
>> service
>> SEVERE: An exception or error occurred in the container during the
>> request processing
>> java.lang.NullPointerException
>>    at
>> com 
>> .mysql.jdbc.ResultSetImpl.setRowPositionValidity(ResultSetImpl.java: 
>> 826)
>>    at com.mysql.jdbc.ResultSetImpl.next(ResultSetImpl.java:7046)
>>    at org.apache.catalina.realm.JDBCRealm.getRoles(JDBCRealm.java: 
>> 632)
>
>
> The JDBC realm is very much the poor relation of the DataSource  
> realm. If
> you can switch, you really should.
>
> This is probably https://issues.apache.org/bugzilla/show_bug.cgi?id=45453
>
> Mark
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: JDBCRealm.getRoles causes NullPointerException

Posted by Mark Thomas <ma...@apache.org>.
DIGLLOYD INC wrote:
> Aug 31, 2008 5:30:48 PM org.apache.catalina.connector.CoyoteAdapter service
> SEVERE: An exception or error occurred in the container during the
> request processing
> java.lang.NullPointerException
>     at
> com.mysql.jdbc.ResultSetImpl.setRowPositionValidity(ResultSetImpl.java:826)
>     at com.mysql.jdbc.ResultSetImpl.next(ResultSetImpl.java:7046)
>     at org.apache.catalina.realm.JDBCRealm.getRoles(JDBCRealm.java:632)


The JDBC realm is very much the poor relation of the DataSource realm. If
you can switch, you really should.

This is probably https://issues.apache.org/bugzilla/show_bug.cgi?id=45453

Mark


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org