Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
-none-

-none-

2007-10-04       - By David Smith

 Back
Add validationQuery="select 1" to your <Resource .../> definition to
cause the database pool to test connections and regenerate them as
necessary before your code gets a connection.

--David

Josu? Alcalde Gonz?lez wrote:
> I am having a problem with DBCP.
>
> It is a problem with my applications written last year for
> apache-tomcat-5 (See http://cat-5.ora-code.com).5. They worked perfectly but I will soon need
> apache-tomcat-6 (See http://cat-6.ora-code.com) and I have upgraded my servers.
>
> I haven't had any problem with my old applications until I discovered
> every morning an exception occurs in my applications related to database
> connection.
>
> It is not a very big problem (connection fails, an error is reported to
> the user, the user tries it again and it works) but it is really
> annoying.
>
> Has something important changed in DBCP which can cause such a problem?
>
> Of course, I suppose you will need more tips to help me.
> As I have said, I use the default datasource and connection pool system
> included with tomcat.
>
> I use to declare my datasource in META-INF/context.xml. For example:
>
>
> -- ---- ---- ---- ---- ---- ---META-INF/context.xml-- ---- ---- ---- ---- --
>
> <?xml version="1.0" encoding="UTF-8 (See http://UTF-8.ora-code.com)"?>
>
> <Context debug="5" reloadable="true" crossContext="true">
>
>   <Resource name="jdbc/GesdocDB" auth="Container"
>                 type="javax.sql.DataSource" maxActive="100" maxIdle="30"
>                 maxWait="1000" username="gesdocweb" password="*******"
>                 driverClassName="com.mysql.jdbc.Driver"
>                 url="jdbc:mysql://127.0.0.1:3306/gesdoc"/>
>
> </Context>
>
> -- ---- ---- ---- ---- ---- ---META-INF/context.xml-- ---- ---- ---- ---- --
>
>
> I use two different ways to access db in different apps. I have used
> JDBC+common-db-utils and Hibernate and I am having this problem with
> both.
> Since JDBC access is more transparent than Hibernate, I will try to give
> you enough info about how the connection is done.
>
> This would be a tipical conection to database to chek the password of a
> user (sorry, the code is in spanish):
>
> -- ------ es.csa.dipu.gesdoc.consultas.ConsultasUsuario -- ------
>
> 80 public static User getUsuarioConLogin(String login)  throws
> DataAccessException {
> 81   String sql = "SELECT idUsuario, login, nombre, apellido1, "
> 82               + "  apellido2, perfil, cambiarPassword, "
> 83               + "  password, estado "
> 84               + "FROM Usuarios WHERE login = ?;";
> 85   try {
> 86     QueryRunner run = new QueryRunner(DbUtils.getDataSource());
> 87     ResultSetHandler h = new BeanHandler(Usuario.class);
> 88     return (Usuario) run.query(sql, login, h);
> 89   } catch (Exception e) {
> 90     log.warn(msg.get("ERROR_CONSULTA_USUARIO"), e);
> 91     throw new
> DataAccessException(msg.get("ERROR_CONSULTA_USUARIO"),e);
> 92   }
> 93 }
>
> -- ------ es.csa.dipu.gesdoc.consultas.ConsultasUsuario -- ------
>
> run.query() will close resultsets, statements and connection and it
> seems the problem is when it tries to close connection. This is a trace
> of the error:
>
> 04-oct-2007 (See http://oct-2007.ora-code.com) 8:52:12 es.csa.dipu.gesdoc.consultas.ConsultasUsuario
> getUsuarioConLogin
> ADVERTENCIA: Se ha producido un error al consultar en la tabla usuarios.
> java.sql.SQLException: Already closed.
>         at
> org.apache.tomcat.dbcp.dbcp.PoolableConnection.close(PoolableConnection.java
:84)
>         at org.apache.tomcat.dbcp.dbcp.PoolingDataSource
> $PoolGuardConnectionWrapper.close(PoolingDataSource.java:181)
>         at org.apache.commons.dbutils.DbUtils.close(DbUtils.java:38)
>         at
> org.apache.commons.dbutils.QueryRunner.close(QueryRunner.java:524)
>         at
> org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:311)
>         at
> org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:285)
>         at
> es.csa.dipu.gesdoc.consultas.ConsultasUsuario.getUsuarioConLogin
(ConsultasUsuario.java:88)
>         at
> es.csa.dipu.gesdoc.beans.LoginBean.doLogin(LoginBean.java:123)
>         at sun.reflect.GeneratedMethodAccessor694.invoke(Unknown Source)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:585)
>         at
> org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
>         at
> org.apache.myfaces.application.ActionListenerImpl.processAction
(ActionListenerImpl.java:61)
>         at javax.faces.component.UICommand.broadcast(UICommand.java:109)
>         at
> javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
>         at
> javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
>         at
> org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute
(InvokeApplicationExecutor.java:32)
>         at
> org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
>         at
> org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
>         at
> javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:290)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:206)
>         at
> org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter
.java:147)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:235)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:206)
>         at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve
.java:233)
>         at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve
.java:175)
>         at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
>         at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>         at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:109)
>         at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
>         at
> org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
>         at
> org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
>         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:889)
>         at org.apache.tomcat.util.threads.ThreadPool
> $ControlRunnable.run(ThreadPool.java:690)
>         at java.lang.Thread.run(Thread.java:595)
> 04-oct-2007 (See http://oct-2007.ora-code.com) 8:52:18 es.csa.dipu.gesdoc.consultas.ConsultasUsuario
> getUsuarioConLogin
> ADVERTENCIA: Se ha producido un error al consultar en la tabla usuarios.
> java.sql.SQLException: Already closed.
>         at
> org.apache.tomcat.dbcp.dbcp.PoolableConnection.close(PoolableConnection.java
:84)
>         at org.apache.tomcat.dbcp.dbcp.PoolingDataSource
> $PoolGuardConnectionWrapper.close(PoolingDataSource.java:181)
>         at org.apache.commons.dbutils.DbUtils.close(DbUtils.java:38)
>         at
> org.apache.commons.dbutils.QueryRunner.close(QueryRunner.java:524)
>         at
> org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:311)
>         at
> org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:285)
>         at
> es.csa.dipu.gesdoc.consultas.ConsultasUsuario.getUsuarioConLogin
(ConsultasUsuario.java:88)
>         at
> es.csa.dipu.gesdoc.beans.LoginBean.doLogin(LoginBean.java:123)
>         at sun.reflect.GeneratedMethodAccessor694.invoke(Unknown Source)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:585)
>         at
> org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
>         at
> org.apache.myfaces.application.ActionListenerImpl.processAction
(ActionListenerImpl.java:61)
>         at javax.faces.component.UICommand.broadcast(UICommand.java:109)
>         at
> javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
>         at
> javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
>         at
> org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute
(InvokeApplicationExecutor.java:32)
>         at
> org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
>         at
> org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
>         at
> javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:290)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:206)
>         at
> org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter
.java:147)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:235)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:206)
>         at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve
.java:233)
>         at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve
.java:175)
>         at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
>         at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>         at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:109)
>         at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
>         at
> org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
>         at
> org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
>         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:889)
>         at org.apache.tomcat.util.threads.ThreadPool
> $ControlRunnable.run(ThreadPool.java:690)
>         at java.lang.Thread.run(Thread.java:595)
>
>
> And that's all. Thanks for any help. I think the key is that it doesn't
> fail in tomcat 5.5, but I don't know how to continue.
>
>
>
>
>
>
> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
> To start a new topic, e-mail: users@(protected)
> To unsubscribe, e-mail: users-unsubscribe@(protected)
> For additional commands, e-mail: users-help@(protected)
>
>  


-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)