I think you are running into a MySQL database connection timeout. You can use a 
MySQL admin interface (command line, PHPAdmin, MySQL Workbench, etc.) to verify 
the idle connection timeout limit.

There have been comments on the web concerning this. One such discussion and a 
solution are here:

http://lists.mysql.com/java/6578

The explanation of the parameters given in the above link can be found here:

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

Based on those two references, you'll need to modify your Realm database URL:

connectionURL="jdbc:mysql://localhost:3306/yucca123_thejarbar&autoReconnect=true&reconnectAtTxEnd=true"

Note, I have not tried this, so test before production.

The other solution mentioned is to use a DataSource Realm. This requires you to 
configure a JNDI datasource describing your database connection as well as the 
DataSource Realm.

You can add all of this information in your web application's 
META-INF/context.xml file if it's application-specific.

If this is a host or service-based definition, then you'll have to define the 
JNDI resources in a GlobalNamingResources element. See the following:

http://tomcat.apache.org/tomcat-6.0-doc/config/globalresources.html

Note the warning that this resource will not be available to an individual web 
application unless you use a ResourceLink in your META-INF/context.xml file.  
See the globalresources link above for an example.

Since you're using this connection for container managed authentication and 
authorization, I'm not sure why your web application would need access to this 
resource.

However, it's 3 am, so I may have missed a few points that Chuck, Charles, or 
Pid will be happy to correct.

To summarize - it seems the easiest fix is to add the following properties to 
your JDBC url:

autoReconnect=true
reconnectAtTxEnd=true

Add them to the end of the URL, connected with ampersands.

I hope this gets you up and running.

. . . . . just my two cents

/mde/

--- On Sun, 5/30/10, Yucca Nel <yucca...@live.co.za> wrote:

> From: Yucca Nel <yucca...@live.co.za>
> Subject: Re: problems at thejarbar.org
> To: "Tomcat Users List" <users@tomcat.apache.org>
> Date: Sunday, May 30, 2010, 9:34 AM
> Yes, but I am using JDBC and followed
> the setup step by step from tomcat docs....
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <Server
>    port="9170">
>  <Listener
> className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
>  <Listener
> className="org.apache.catalina.core.JasperListener" />
>  <Listener
> className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
>  <GlobalNamingResources>
>    <Resource
>      auth="Container"
>      description="User database"
>      name="UserDatabase"
>  
>    type="org.apache.catalina.UserDatabase"
>      pathname="conf/tomcat-users.xml"
>  
>    factory="org.apache.catalina.users.MemoryUserDatabaseFactory"/>
>  </GlobalNamingResources>
>  <Service
>      name="Catalina">
>    <Connector
>        port="9670"
>        minSpareThreads="1"
>        address="127.0.0.1"
>        maxThreads="50"
>        maxSpareThreads="3"
>        connectionTimeout="30000"
>        protocol="AJP/1.3">
>    </Connector>
>    <Engine
>    
>    defaultHost="thejarbar.org"
>        name="Catalina">
>      <Realm
> className="org.apache.catalina.realm.UserDatabaseRealm"/><Realm
> className="org.apache.catalina.realm.JDBCRealm"
>            
> driverName="com.mysql.jdbc.Driver"
>            
> connectionURL="jdbc:mysql://localhost:3306/yucca123_thejarbar"
>   connectionName="yucca123_tom"
>            
> connectionPassword="myPass"
>       userTable="users"
> userNameCol="user_name" userCredCol="user_pass"
>   userRoleTable="user_roles"
> roleNameCol="role_name"/><Host
>      
>    appBase="/home/yucca123/public_html"
>      
>    name="thejarbar.org">
>    
>    <Alias>www.thejarbar.org</Alias>
>        <Context
>        
>    path="/the_jar_bar">
>          <Listener
> className="org.apache.catalina.startup.TldConfig"/>
>        </Context>
>        <Context
>        
>    docBase="/usr/local/tomcat/users/yucca123/tomcat/webapps/manager"
>        
>    path="/manager"
>        
>    privileged="true"
>        
>    reloadable="true">
>          <Listener
> className="org.apache.catalina.startup.TldConfig"/>
>          <ResourceEnvRef
>            name="users"
>        
>    type="org.apache.catalina.UserDatabase"/>
>        </Context>
>        <Context
>        
>    docBase="the_jar_bar"
>            path=""
>        
>    reloadable="true">
>          <Listener
> className="org.apache.catalina.startup.TldConfig"/>
>        </Context>
>      </Host>
>    </Engine>
>  </Service>
> </Server>
> May be missing something...
> 
> http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html#JDBC%20Data%20Sources
> 
> This error does not occur every time
> 
> 
> 
> 
> --------------------------------------------------
> From: "Jeff" <jwi...@cox.net>
> Sent: Sunday, May 30, 2010 5:54 PM
> To: "Tomcat Users List" <users@tomcat.apache.org>
> Subject: Re: problems at thejarbar.org
> 
> > would this help?
> > 
> > http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html#Common%20Problems
> > 
> > 
> > On 5/30/2010 10:08 AM, Yucca Nel wrote:
> >> The following is becoming a common and serious
> problem and I am unable to find a google solution for it...
> >> I have never seen sych an error and it does not
> appear to be common enough to get many google hits but when
> it happens, no one is able to register at my site...
> >> 
> >> Stck trace:
> >> 
> >> Caused by:
> com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
> Communications link failure
> >> 
> >> The last packet successfully received from the
> server was 4,290,127 milliseconds ago.  The last packet
> sent successfully to the server was 0 milliseconds ago.
> >> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
> >> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
> >> at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
> >> at
> java.lang.reflect.Constructor.newInstance(Constructor.java:513)
> >> at
> com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
> >> at
> com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
> >> at
> com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3052)
> >> at
> com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2938)
> >> at
> com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3481)
> >> at
> com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)
> >> at
> com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2109)
> >> at
> com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2648)
> >> at
> com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2077)
> >> at
> com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2228)
> >> at
> org.apache.catalina.realm.JDBCRealm.getPassword(JDBCRealm.java:550)
> >> ... 15 more
> >> Caused by: java.io.EOFException: Can not read
> response from server. Expected to read 4 bytes, read 0 bytes
> before connection was unexpectedly lost.
> >> at
> com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2497)
> >> at
> com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2949)
> >> ... 23 more
> >> ERROR TP-Processor6
> org.hibernate.util.JDBCExceptionReporter - Communications
> link failure
> >> 
> >> The last packet successfully received from the
> server was 4,299,820 milliseconds ago.  The last packet
> sent successfully to the server was 0 milliseconds ago.
> >> ERROR TP-Processor6
> org.hibernate.util.JDBCExceptionReporter - No operations
> allowed after connection closed.Connection was implicitly
> closed by the driver.
> >> ERROR TP-Processor6
> org.hibernate.util.JDBCExceptionReporter - No operations
> allowed after connection closed.Connection was implicitly
> closed by the driver.
> >> ERROR TP-Processor6
> org.hibernate.util.JDBCExceptionReporter - No operations
> allowed after connection closed.Connection was implicitly
> closed by the driver.
> >> ERROR TP-Processor6
> org.hibernate.util.JDBCExceptionReporter - No operations
> allowed after connection closed.Connection was implicitly
> closed by the driver.
> >> ERROR TP-Processor6
> org.hibernate.util.JDBCExceptionReporter - No operations
> allowed after connection closed.Connection was implicitly
> closed by the driver.
> >> ERROR TP-Processor6
> org.hibernate.util.JDBCExceptionReporter - No operations
> allowed after connection closed.Connection was implicitly
> closed by the driver.
> >> ERROR TP-Processor6
> org.hibernate.util.JDBCExceptionReporter - No operations
> allowed after connection closed.Connection was implicitly
> closed by the driver.
> >> ERROR TP-Processor6
> org.hibernate.util.JDBCExceptionReporter - No operations
> allowed after connection closed.Connection was implicitly
> closed by the driver.
> >> ERROR TP-Processor6
> org.apache.catalina.core.ContainerBase.[Catalina].[thejarbar.org].[/].[Faces
> Servlet]The registration code that leads to error is as
> follows: Form:<!--Created by IntelliJ IDEA.User:
> ownerDate: 02.mai.2010Time: 14:07:31To change this template
> use File | Settings | File Templates.--><%...@page
> contentType="text/html" language="java" %><%...@page
> pageEncoding="UTF-8"%><%...@taglib uri="http://java.sun.com/jsf/core"; 
> prefix="f" %><%@
> taglib prefix="h" uri="http://java.sun.com/jsf/html";
> %><html><head> 
>    <meta http-equiv="Content-Type"
> content="text/html; charset=UTF-8" /> 
>    <title>The jar bar::
> register</title></head><f:view> 
>    <body
> style="background-color:#7b68ee;margin:auto"> 
>    <div align="center"> <div
> align="center" id="header"><jsp:include
> page="/header.jsp"/></div> <div align="center"
> id="centred-content"style="border-width:3px; border-style:
> solid; border-color: #7fffd4;width:800px">   
>          <div id="h1"
> align="center">           
>      <h:outputText
> value="#{registerMsg.h1}" style="color:white;
> font-family:fantasy;font-size:x-large;"/>   
>              <div
> id="p1" align="center">         
>        
>    <h:outputText value="#{registerMsg.p1}"
> style="font-size:large;margin-bottom:5em;color:white;"/>
> <h:form>           
>          </h:form> 
>            
>    </div> <h:form>   
>              
>    <h:panelGrid columns="2">
> <h:outputText value="*#{registerMsg.name}:"
> style="color:yellow;"/> <h:inputText id="name"
> value="#{user.entity.firstName}"
> title="#{registerMsg.nameTitle}"required="true">
> <f:validateLength minimum="3"maximum="30"/>
> <h:message for="name"style="color:red;"/>
> </h:inputText>         
>            
>    <h:outputText
> value="#{registerMsg.surname}:" style="color:yellow;"/>
> <h:inputText id="surname" value="#{user.entity.lastName}"
> title="#{registerMsg.surnameTitle}" required="false">
> <f:validateLength minimum="3"maximum="30"/>
> <h:message for="surname" style="color:red;" />
> </h:inputText>         
>            
>    <h:outputText
> value="*#{registerMsg.email}:" style="color:yellow;"/>
> <h:inputText id="email" value="#{user.entity.userEmail}"
> title="#{registerMsg.emailTitle}"required="true">
> <f:validator validatorId="emailEValidate"/>
> <f:validator validatorId="emailPValidate"/>
> <h:message for="email" style="color:red;"/>
> </h:inputText>         
>            
>    <h:outputText
> value="*#{registerMsg.userName}:" style="color:yellow;"/>
> <h:inputText id="uName" value="#{user.entity.userName}"
> title="#{registerMsg.userNameTitle}"required="true">
> <f:validator validatorId="uNameEValidate"/>
> <f:validateLength maximum="20" minimum="6"/>
> <h:message for="uName"
> style="color:red;"/></h:inputText> <h:outputText
> value="*#{registerMsg.password}:" style="color:yellow;"/>
> <h:inputSecret id="pass" value="#{user.entity.userPass}"
> title="#{registerMsg.passwordTitle}*"required="true">
> <f:validateLength minimum="6"maximum="20" />
> <h:message for="pass" style="color:red;"/>
> </h:inputSecret>         
>        
>    </h:panelGrid> <h:commandButton
> action="#{user.create}"
> value="#{registerMsg.register}"style="color:#20b2aa;" />
> <br>             
>    </h:form>       
>      </div>     
>        <div id="footer"
> align="center">           
>      <jsp:include
> page="/Footer.jsp"/>         
>    </div>     
>    </div> 
>    </div>
> </body></f:view></html>   
> Anyone have any thoughts as to why this is happening?
> >> 
> >> 
> >> 
> >> 
> >> No virus found in this incoming message.
> >> Checked by AVG - www.avg.com
> >> Version: 9.0.819 / Virus Database: 271.1.1/2904 -
> Release Date: 05/29/10 13:25:00
> >> 
> >> 
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
> 
> 





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

Reply via email to