tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josué Alcalde González <jalca...@csa.es>
Subject Problems with DBCP in tomcat6
Date Thu, 04 Oct 2007 08:21:29 GMT
I am having a problem with DBCP.

It is a problem with my applications written last year for
apache-tomcat-5.5. They worked perfectly but I will soon need
apache-tomcat-6 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"?>

<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 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 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@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message