tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pid <...@pidster.com>
Subject Re: java.lang.IllegalStateException: Timer already cancelled
Date Tue, 06 Jul 2010 11:30:12 GMT
On 06/07/2010 11:34, Yevgen Krapiva wrote:
> I've tried today the latest driver available - 5.1.13. 
> I've places the driver to %CATALINA_HOME%/lib.
> 
> I also tried to move it to WEB-INF\lib, but it is appeared that Tomcat
> (I'm using 6.0.26) doesn't see
> it when trying to create connection from a DataSource. He says
> ClassNotFoundException.

You'll need to define the DataSource (and anything else that depends on
it, like a Realm*) in myapp/META-INF/context.xml if you place the driver
jar in WEB-INF/lib.  Global resources defined in server.xml can't use
jars located in a web app ClassLoader.

> I don't know why but when I test it using Class.forName() - it exists.
> I think Tomcat doesn't use servlet classloader.
> 
> So, returning to the problem , I think the problem is with
> org.apache.tomcat.dbcp.pool.impl.EvictionTimer class, because
> it is actually throws exception.

It is indeed.  I was looking at a similar problem in the MySQL driver
and completely failed to read the stacktrace properly, my apologies.

The o.a.tomcat.dbcp classes are a repackaged version of commons-dbcp &
commons-pool so we'll have to look in the source there.

 http://svn.apache.org/repos/asf/commons/proper/dbcp/
 http://svn.apache.org/repos/asf/commons/proper/pool/

And:

 http://svn.apache.org/repos/asf/commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/EvictionTimer.java


So, is your application the only application running on the server?


p


* DataSourceRealms defined with DataSources in the Context definition
need localDataSource=true setting as per:

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

> 2010/7/6 Pid <pid@pidster.com <mailto:pid@pidster.com>>
> 
>     On 06/07/2010 08:22, Pid wrote:
>     > On 06/07/2010 08:05, Yevgen Krapiva wrote:
>     >> Hi guys.
>     >>
>     >> I have a servlet that uses connection pool with the use of MySQL
>     driver.
>     >> When I start or reload Tomcat the application works fine, then if I
>     >> redeploy my application it cannot get a connection from a
>     DataSource object.
>     >> The following exception is thrown:
>     >>
>     >> java.lang.IllegalStateException: Timer already cancelled.
>     >>
>     >> java.util.Timer.sched(Timer.java:354)
>     >> java.util.Timer.schedule(Timer.java:222)
>     >>
>     org.apache.tomcat.dbcp.pool.impl.EvictionTimer.schedule(EvictionTimer.java:64)
>     >>
>     org.apache.tomcat.dbcp.pool.impl.GenericObjectPool.startEvictor(GenericObjectPool.java:1647)
>     >>
>     org.apache.tomcat.dbcp.pool.impl.GenericObjectPool.setTimeBetweenEvictionRunsMillis(GenericObjectPool.java:843)
>     >>
>     org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1173)
>     >>
>     org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
>     >>
>     basis.onlineorder.commons.dao.UserDAOJdbcImpl.getUsers(UserDAOJdbcImpl.java:133)
>     >> org.apache.jsp.users_jsp.getUsersList(users_jsp.java:31)
>     >> org.apache.jsp.users_jsp._jspService(users_jsp.java:164)
>     >> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
>     >> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>     >>
>     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
>     >>
>     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
>     >> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
>     >> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>     >>
>     >> I have not found anything I can do with this on the internet.
>     Perhaps I've
>     >> found that I might have a relation to
>     >> timeBetweenEvictionRunsMillis parameter ( in <Resource> configuration
>     >> section ).
>     >>
>     >> I don't know if it is important, here is my configuration in
>     context.xml
>     >> file:
>     >>
>     >> <Resource name="jdbc/onlineorder"
>     >> auth="Container"
>     >> type="javax.sql.DataSource"
>     >> username="user"
>     >> password="password"
>     >> driverClassName="com.mysql.jdbc.Driver"
>     >>
>     url="jdbc:mysql://localhost/mydb?useUnicode=true&amp;characterEncoding=utf8"
>     >> maxActive="10"
>     >> maxIdle="5"
>     >> testOnBorrow="true"
>     >> testWhileIdle="true"
>     >> timeBetweenEvictionRunsMillis="10000"
>     >> minEvictableIdleTimeMillis="60000"
>     >> />
>     >>
>     >> Did anyone face with this problem ?
>     >
>     > Exactly which version of the MySQL driver are you using?
>     >
>     > This is a side-effect of the memory leak prevention in Tomcat 6.0.20+
>     > which aims to stop Timers that haven't been properly shutdown.
> 
>     Correction, Timer Thread termination was introduced in 6.0.24.
>     It's optional from 6.0.27 with the clearReferencesStopTimerThreads flag.
> 
>     You might consider filing a bug with MySQL requesting that they check
>     that the Timer is actually running.
> 
> 
>     p



Mime
View raw message