tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: JDBCRealm.getRoles causes NullPointerException
Date Tue, 16 Sep 2008 21:00:17 GMT
-----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


Mime
View raw message