You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Gregor Schneider <rc...@googlemail.com> on 2007/06/04 09:51:53 UTC

Strange MySQL-Behaviour with JDBC-Realm

Hi guys,

we're running Tomcta 5.5 and MySQL 5 (InnoDB), OS is Debian. Tomcat
authentication is done via a JDBC-Realm.

Every now and then FormAuthenticator is throwing the following Exception:

2007-06-04 01:41:02,762 ERROR           localSearch.log
[TP-Processor2]:        Exception
performing authentication
com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException:
Communications link failur
e during commit(). Transaction resolution unknown.
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:888)
        at com.mysql.jdbc.Connection.commit(Connection.java:2259)
        at org.apache.catalina.realm.JDBCRealm.getPassword(JDBCRealm.java:568)
        at org.apache.catalina.realm.JDBCRealm.authenticate(JDBCRealm.java:399)
        at org.apache.catalina.realm.JDBCRealm.authenticate(JDBCRealm.java:347)
        at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthentica
tor.java:257)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.ja
va:416)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:392)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:10
7)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
        at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
        at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
        at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
        at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:88
9)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:6
84)
        at java.lang.Thread.run(Thread.java:595)

Since Google is my friend, I found this link telling me that MySQL's
ConnectorJ times out after 8 hours - *ouch*:
http://dev.mysql.com/doc/refman/5.0/en/connector-j-usagenotes-troubleshooting.html#qandaitem-24-4-5-3-4

Developers there are told to use a connection-pool that can handle
this problem. They discourage anybody to use the
"autoconnect"-feature, since this might be unsafe and become
depricated soon.

Well, well, I'm using the following connection-pool within Tomcat:

<?xml version="1.0" encoding="UTF-8"?>
<Context>
  <Resource
    auth="Container"
    description="DB Connection for SSO"
    name="jdbc/SSODS"
    type="javax.sql.DataSource"
    factory="org.apache.commons.dbcp.BasicDataSourceFactory"
    driverClassName="com.mysql.jdbc.Driver"
    username="XXX"
    password="XXX"
    url="jdbc:mysql://db/apacheSSO"
    maxIdle="5"
    maxWait="10000"
    maxActive="10"
    validationQuery="SELECT 1"
    testOnBorrow="true"
    testWhileIdle="true"
    timeBetweenEvictionRunsMillis="10000"
    minEvictableIdleTimeMillis="28800"
    poolPreparedStatements="true"
    removeAbandoned="true"
    removeAbandonedTimeout="300"
    logAbandoned="false"/>
</Context>

Seems that this connection-pool does not handle this problem properly.

So:

Does any of you gyus have the same problem and has a working solution
fori t? I hate it to check the Tomcat's ERROR-log in the morning and
every day I see a file having a size > 0...

I'm wondering if I simply should add the autoconnect-feature (which is
such a bad, bad thing....) to my connection-pool...

Any oppinions on this appreciated

Gregor
-- 
what's puzzlin' you, is the nature of my game
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
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: Strange MySQL-Behaviour with JDBC-Realm

Posted by Kris <kr...@kremsoft.com>.
Did autoreconnect solve your problem?




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


Re: Strange MySQL-Behaviour with JDBC-Realm

Posted by Gregor Schneider <rc...@googlemail.com>.
Hi David,

will give that a try. If the exception persists, I'll go for
autoreconnect, will report here.

Cheers

Gregor
-- 
what's puzzlin' you, is the nature of my game
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
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: Strange MySQL-Behaviour with JDBC-Realm

Posted by David Short <ds...@san.rr.com>.
You may want to try it with explicit values to see if that makes a
difference.  I know NetBeans (different subject) has a problem when the port
number is specified and is other that 3306 (default).  Just an idea. 

-----Original Message-----
From: Gregor Schneider [mailto:rc46fi@googlemail.com] 
Sent: Monday, June 04, 2007 1:17 AM
To: Tomcat Users List; dshort@san.rr.com
Subject: Re: Strange MySQL-Behaviour with JDBC-Realm

Hi David,

from
http://dev.mysql.com/doc/refman/4.1/en/connector-j-reference-configuration-p
roperties.html:

========[snipp]=================
If the hostname is not specified, it defaults to 127.0.0.1. If the port is
not specified, it defaults to 3306, the default port number for MySQL
servers.
========[snapp]=================

If nobody has a suggestion on that topic, I guess I'll try it with
"autoreconnect", although I'm not happy with that since it's depricated

Thanks anyway!

Gregor
--
what's puzzlin' you, is the nature of my game
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
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: Strange MySQL-Behaviour with JDBC-Realm

Posted by Gregor Schneider <rc...@googlemail.com>.
Hi David,

from http://dev.mysql.com/doc/refman/4.1/en/connector-j-reference-configuration-properties.html:

========[snipp]=================
If the hostname is not specified, it defaults to 127.0.0.1. If the
port is not specified, it defaults to 3306, the default port number
for MySQL servers.
========[snapp]=================

If nobody has a suggestion on that topic, I guess I'll try it with
"autoreconnect", although I'm not happy with that since it's
depricated

Thanks anyway!

Gregor
-- 
what's puzzlin' you, is the nature of my game
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
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: Strange MySQL-Behaviour with JDBC-Realm

Posted by David Short <ds...@san.rr.com>.
Shouldn't your connection URL look something like this:
jdbc:mysql//db:3306/apacheSSO instead of jdbc:mysql://db/apacheSSO?  Not
sure if this means anything, since you say it's already working...  It just
looks strange.

-----Original Message-----
From: Gregor Schneider [mailto:rc46fi@googlemail.com] 
Sent: Monday, June 04, 2007 12:52 AM
To: Tomcat Users List
Subject: Strange MySQL-Behaviour with JDBC-Realm

Hi guys,

we're running Tomcta 5.5 and MySQL 5 (InnoDB), OS is Debian. Tomcat
authentication is done via a JDBC-Realm.

Every now and then FormAuthenticator is throwing the following Exception:

2007-06-04 01:41:02,762 ERROR           localSearch.log
[TP-Processor2]:        Exception
performing authentication
com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException:
Communications link failur
e during commit(). Transaction resolution unknown.
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:888)
        at com.mysql.jdbc.Connection.commit(Connection.java:2259)
        at
org.apache.catalina.realm.JDBCRealm.getPassword(JDBCRealm.java:568)
        at
org.apache.catalina.realm.JDBCRealm.authenticate(JDBCRealm.java:399)
        at
org.apache.catalina.realm.JDBCRealm.authenticate(JDBCRealm.java:347)
        at
org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthent
ica
tor.java:257)
        at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase
.ja
va:416)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126
)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105
)
        at
org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:392)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:10
7)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at
org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
        at
org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
        at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
        at
org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
        at
org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java
:88
9)
        at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:6
84)
        at java.lang.Thread.run(Thread.java:595)

Since Google is my friend, I found this link telling me that MySQL's
ConnectorJ times out after 8 hours - *ouch*:
http://dev.mysql.com/doc/refman/5.0/en/connector-j-usagenotes-troubleshootin
g.html#qandaitem-24-4-5-3-4

Developers there are told to use a connection-pool that can handle this
problem. They discourage anybody to use the "autoconnect"-feature, since
this might be unsafe and become depricated soon.

Well, well, I'm using the following connection-pool within Tomcat:

<?xml version="1.0" encoding="UTF-8"?>
<Context>
  <Resource
    auth="Container"
    description="DB Connection for SSO"
    name="jdbc/SSODS"
    type="javax.sql.DataSource"
    factory="org.apache.commons.dbcp.BasicDataSourceFactory"
    driverClassName="com.mysql.jdbc.Driver"
    username="XXX"
    password="XXX"
    url="jdbc:mysql://db/apacheSSO"
    maxIdle="5"
    maxWait="10000"
    maxActive="10"
    validationQuery="SELECT 1"
    testOnBorrow="true"
    testWhileIdle="true"
    timeBetweenEvictionRunsMillis="10000"
    minEvictableIdleTimeMillis="28800"
    poolPreparedStatements="true"
    removeAbandoned="true"
    removeAbandonedTimeout="300"
    logAbandoned="false"/>
</Context>

Seems that this connection-pool does not handle this problem properly.

So:

Does any of you gyus have the same problem and has a working solution fori
t? I hate it to check the Tomcat's ERROR-log in the morning and every day I
see a file having a size > 0...

I'm wondering if I simply should add the autoconnect-feature (which is such
a bad, bad thing....) to my connection-pool...

Any oppinions on this appreciated

Gregor
--
what's puzzlin' you, is the nature of my game
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
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: Strange MySQL-Behaviour with JDBC-Realm

Posted by David Smith <dn...@cornell.edu>.
I don't think autoReconnect would help.  It'd still throw the exception 
and then re-connect to the database so the code can retry.  
Unfortunately it doesn't just silently reconnect and perform the query.

You have configured both testOnBorrow and a validation query, so the 
connection is verified working before the attempt to retrieve a 
password.  You might want to check firewalls or network hardware between 
your tomcat server and database server.  This smells like a network issue.

--David

Gregor Schneider wrote:
> Hi guys,
>
> we're running Tomcta 5.5 and MySQL 5 (InnoDB), OS is Debian. Tomcat
> authentication is done via a JDBC-Realm.
>
> Every now and then FormAuthenticator is throwing the following Exception:
>
> 2007-06-04 01:41:02,762 ERROR           localSearch.log
> [TP-Processor2]:        Exception
> performing authentication
> com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException:
> Communications link failur
> e during commit(). Transaction resolution unknown.
>        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:888)
>        at com.mysql.jdbc.Connection.commit(Connection.java:2259)
>        at 
> org.apache.catalina.realm.JDBCRealm.getPassword(JDBCRealm.java:568)
>        at 
> org.apache.catalina.realm.JDBCRealm.authenticate(JDBCRealm.java:399)
>        at 
> org.apache.catalina.realm.JDBCRealm.authenticate(JDBCRealm.java:347)
>        at 
> org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthentica 
>
> tor.java:257)
>        at 
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.ja 
>
> va:416)
>        at 
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) 
>
>        at 
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) 
>
>        at 
> org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:392) 
>
>        at 
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:10 
>
> 7)
>        at 
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) 
>
>        at 
> org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
>        at 
> org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
>        at 
> org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
>        at 
> org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697) 
>
>        at 
> org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:88 
>
> 9)
>        at 
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:6 
>
> 84)
>        at java.lang.Thread.run(Thread.java:595)
>
> Since Google is my friend, I found this link telling me that MySQL's
> ConnectorJ times out after 8 hours - *ouch*:
> http://dev.mysql.com/doc/refman/5.0/en/connector-j-usagenotes-troubleshooting.html#qandaitem-24-4-5-3-4 
>
>
> Developers there are told to use a connection-pool that can handle
> this problem. They discourage anybody to use the
> "autoconnect"-feature, since this might be unsafe and become
> depricated soon.
>
> Well, well, I'm using the following connection-pool within Tomcat:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Context>
>  <Resource
>    auth="Container"
>    description="DB Connection for SSO"
>    name="jdbc/SSODS"
>    type="javax.sql.DataSource"
>    factory="org.apache.commons.dbcp.BasicDataSourceFactory"
>    driverClassName="com.mysql.jdbc.Driver"
>    username="XXX"
>    password="XXX"
>    url="jdbc:mysql://db/apacheSSO"
>    maxIdle="5"
>    maxWait="10000"
>    maxActive="10"
>    validationQuery="SELECT 1"
>    testOnBorrow="true"
>    testWhileIdle="true"
>    timeBetweenEvictionRunsMillis="10000"
>    minEvictableIdleTimeMillis="28800"
>    poolPreparedStatements="true"
>    removeAbandoned="true"
>    removeAbandonedTimeout="300"
>    logAbandoned="false"/>
> </Context>
>
> Seems that this connection-pool does not handle this problem properly.
>
> So:
>
> Does any of you gyus have the same problem and has a working solution
> fori t? I hate it to check the Tomcat's ERROR-log in the morning and
> every day I see a file having a size > 0...
>
> I'm wondering if I simply should add the autoconnect-feature (which is
> such a bad, bad thing....) to my connection-pool...
>
> Any oppinions on this appreciated
>
> Gregor


---------------------------------------------------------------------
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