Tomcat JDBC Realm Authentication Bug with MySQL?

From: Bruno Beloff (bruno.beloff_at_opmath.com)
Date: 11/28/03


Date: Fri, 28 Nov 2003 20:14:25 +0000

Hi.

I've found what might be a nasty bug, running Tomcat 4.1.29 on Mandrake 9.0
Linux with MySQL 4.0. I don't know what to make of this, and I'd really
appreciate any ideas.

I have a web application that runs fine all the time, except for one
instance: this is the case where the application has been dormant for some
time (perhaps 8 hours). At this point I try to access a URL controlled by a
security constraint. I get my log in form, complete the form, and attempt
to submit it. But I get a blank page, instead of the correct page.

At this point, Tomcat generates a new log file named catalina_log.<date>.txt
with the following content:

2003-11-28 19:43:48 CoyoteAdapter An exception or error occurred in the
container during the request processing
java.lang.StackOverflowError

Tomcat continues to run, but all further attempts to log in result in
duplicates of the same error. The server.xml entry for the application is
at the foot of this message.

It occurs to me that MySQL drops connections automatically after 8 hours.
That hasn't been a problem for me for the most part, because both my
application's data source configuration and the JDBC realm configuration set
'autoReconnect=true' as part of the JDBC URL. The rest of this application
(which makes use of MySQL via Tomcat's connection pooling) goes on running
fine, even when the authenticator has died.

So what's up? Have I configured the JDBC realm wrong? Is there some
work-around? Help please!

    Bruno.

        <Context className="org.apache.catalina.core.StandardContext"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper" cookies="true"
crossContext="false" debug="1" displayName="Web Bookshop"
docBase="/var/tomcat4/webapps/wb"
mapperClass="org.apache.catalina.core.StandardContextMapper" path="/wb"
privileged="false" reloadable="true" swallowOutput="false" useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWrapper">
          <Loader className="org.apache.catalina.loader.WebappLoader"
checkInterval="15" debug="1" delegate="false"
loaderClass="org.apache.catalina.loader.WebappClassLoader"
reloadable="true"/>
          <Logger className="org.apache.catalina.logger.FileLogger"
debug="0" directory="logs" prefix="localhost_wb_log." suffix=".txt"
timestamp="true" verbosity="1"/>
          <Manager className="org.apache.catalina.session.StandardManager"
algorithm="MD5" checkInterval="60" debug="1" duplicates="0"
expiredSessions="0" maxActive="1" maxActiveSessions="-1"
maxInactiveInterval="-60" pathname="SESSIONS.ser"
randomClass="java.security.SecureRandom" rejectedSessions="0"
sessionCounter="4">
          </Manager>
          <Realm className="org.apache.catalina.realm.JDBCRealm"
connectionName="tomcat" connectionPassword="tomcat"
connectionURL="jdbc:mysql://localhost/wb?autoReconnect=true" debug="9"
driverName="com.mysql.jdbc.Driver" roleNameCol="us_role"
userCredCol="us_password" userNameCol="us_name" userRoleTable="users"
userTable="users" validate="true"/>
          <Resource name="jdbc/wb" scope="Shareable"
type="javax.sql.DataSource"/>
          <ResourceParams name="jdbc/wb">
            <parameter>
              <name>maxWait</name>
              <value>5000</value>
            </parameter>
            <parameter>
              <name>maxActive</name>
              <value>6</value>
            </parameter>
            <parameter>
              <name>password</name>
              <value>tomcat</value>
            </parameter>
            <parameter>
              <name>url</name>
              <value>jdbc:mysql://localhost/wb?autoReconnect=true</value>
            </parameter>
            <parameter>
              <name>driverClassName</name>
              <value>com.mysql.jdbc.Driver</value>
            </parameter>
            <parameter>
              <name>maxIdle</name>
              <value>2</value>
            </parameter>
            <parameter>
              <name>username</name>
              <value>tomcat</value>
            </parameter>
          </ResourceParams>
        </Context>



Relevant Pages

  • Tomcat sessions memory usage and MySQL connections
    ... experiencing freezing of the web server (java or mysql processes take ... now mysql seems to have too many connections all the time. ... On the other side, tomcat seems to have a lot of unused sessions open, ...
    (comp.lang.java.programmer)
  • =?ISO-8859-15?Q?Kompatibilit=E4t_MySQL_mit_Tomcat_+_Tu?= =?ISO-8859-15?Q?rbine/Torqu
    ... wir programmieren Java-Servlets und verwenden dabei u.a. Tomcat und Torque 3.0. Unsere Erfahrungen mit MySQL beschränken sich auf die Version 3.23. Nun wollen wir eine System auf MySQL portieren. ... Schnell den aktuellen JDBC-Treiber heruntergeladen und alle Einstellungen in Torque.properties und unter Eclipse gemacht. ... dass Tomcat anscheinend nicht mehr hochfuhr. ... Bei Torque steht unter "Unterstütze DB" zwar MySQL, allerdings mit dem alten Treibereintrag: ...
    (de.comp.datenbanken.mysql)
  • Re: Tomcat & MySQL Connection Problem
    ... I'm having some trouble connecting to a MySQL database from some Java ... code I have running in Tomcat. ... to see just how much goes on before I get the exception and it looks ... people usually get this exception after a connection has timed out, ...
    (comp.lang.java.programmer)
  • Re: Tomcat and mysql
    ... If using apt-get what packages would I require? ... would I configure Tomcat and MySQL to talk to each other? ... building JSP apps - your choice of Spring MVC, ...
    (Ubuntu)
  • Re: Is running Tomcat as root insecure?
    ... > Is there anything wrong with running Tomcat as root? ... > Since linux only allows root processes to access the standard ports (80, ... Does running Tomcat this way pose any security risks? ...
    (alt.os.linux.suse)