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.=20
> I've places the driver to %CATALINA_HOME%/lib.
>=20
> 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.
>=20
> 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/a=
pache/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=3Dtrue 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>>
>=20
>     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 i=
f 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(EvictionTim=
er.java:64)
>     >>
>     org.apache.tomcat.dbcp.pool.impl.GenericObjectPool.startEvictor(Gen=
ericObjectPool.java:1647)
>     >>
>     org.apache.tomcat.dbcp.pool.impl.GenericObjectPool.setTimeBetweenEv=
ictionRunsMillis(GenericObjectPool.java:843)
>     >>
>     org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicD=
ataSource.java:1173)
>     >>
>     org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicData=
Source.java:880)
>     >>
>     basis.onlineorder.commons.dao.UserDAOJdbcImpl.getUsers(UserDAOJdbcI=
mpl.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:7=
0)
>     >> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>     >>
>     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapp=
er.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> configur=
ation
>     >> section ).
>     >>
>     >> I don't know if it is important, here is my configuration in
>     context.xml
>     >> file:
>     >>
>     >> <Resource name=3D"jdbc/onlineorder"
>     >> auth=3D"Container"
>     >> type=3D"javax.sql.DataSource"
>     >> username=3D"user"
>     >> password=3D"password"
>     >> driverClassName=3D"com.mysql.jdbc.Driver"
>     >>
>     url=3D"jdbc:mysql://localhost/mydb?useUnicode=3Dtrue&amp;characterE=
ncoding=3Dutf8"
>     >> maxActive=3D"10"
>     >> maxIdle=3D"5"
>     >> testOnBorrow=3D"true"
>     >> testWhileIdle=3D"true"
>     >> timeBetweenEvictionRunsMillis=3D"10000"
>     >> minEvictableIdleTimeMillis=3D"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=
=2E20+
>     > which aims to stop Timers that haven't been properly shutdown.
>=20
>     Correction, Timer Thread termination was introduced in 6.0.24.
>     It's optional from 6.0.27 with the clearReferencesStopTimerThreads =
flag.
>=20
>     You might consider filing a bug with MySQL requesting that they che=
ck
>     that the Timer is actually running.
>=20
>=20
>     p



Mime
View raw message