tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Smith <>
Subject Re: first authentication attempt fails - mysql timeout
Date Mon, 21 Apr 2008 17:20:19 GMT
The DatasourceRealm will work.  Drop the autoReconnect parameter from 
the database url though as it's not recommended by the MySQL folks.  
Instead, add a validationQuery to your ResourceParams so database 
connections are tested briefly before they are borrowed from the pool.  
The query can be as simple as 'select 1'.  Also if the Resource you are 
trying to use with the Datasource realm is not a global resource, you'll 
probably need to add localDataSource="true" to the <Realm ... /> definition.

See the docs at 

Info regarding autoReconnect can be found at

(version 5.0 -- you didn't specify mysql version)


Robert Jacobson wrote:
> Hi,
> I have an existing Tomcat configuration that is working well.  
> However, it is running version 4.1.31.  We are updating the platform, 
> so I thought I'd take the opportunity to update Tomcat.  Unfortunately 
> (??) I must stick with the Tomcat 4.1 release.
> I have a test machine on which I have installed 4.1.37.  I only had 
> one issue with the upgrade -- the authentication was not working quite 
> as well as it was before.  While it worked, I had one issue -- when 
> the mysql connection would timeout (after 8 hours by default), the 
> authentication would stop working completely.  With tomcat 4.1.31, 
> there would be an exception w/ stack trace, but it would reconnect and 
> work right away.
> I was authenticating using a mysql database through the JDBCRealm.  I 
> found some posts in the archives ( 
> indicating that switching from the JDBCRealm to DataSourceRealm would 
> resolve the issue, so I have done so.  In the process I also added the 
> autoReconnect parameter to the  connection URL (i.e. 
> jdbc:mysql://localhost:3325/authority?autoReconnect=true )
> I suppose I should note that my configuration is now essentially 
> straight out of the JNDI datasource HOWTO.  I of course changed the 
> username & password, the port number, and the database name.
> I have authentication working with the new configuration.  However, 
> after a mysql connection timeout, the first attempt to authenticate 
> always fails.  The second attempt is successful.
> Is there a way to fix this problem?
> Thanks for your time.

David Smith
Network Operations Supervisor
Department of Entomology
Cornell University
2132 Comstock Hall
Ithaca, NY 14853
Phone: (607) 255-9571
Fax: (607) 255-0940

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

View raw message