tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: JDBCRealm.getRoles causes NullPointerException
Date Tue, 16 Sep 2008 21:00:17 GMT
Hash: SHA1


> 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

Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla -


To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message