You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Giovanni <gi...@yahoo.com> on 2007/06/22 17:31:27 UTC

Tomcat not close file when webapps is stopped

Hi,

I have tomcat 5.5.23 with jdk 1.5.0_12 on Linux Centos 4.5. When stop a webapps
from Tomcat Manager some files of webapp remaining open.

For example I have webapps named cms when is started there is this situation:

[root ~]# lsof -p 3499 | grep webapps
java    3499     22158 588164
/var/lib/tomcat5/webapps/cms/WEB-INF/lib/velocity-tools-view-0.7.jar
java    3499     12991 588163
/var/lib/tomcat5/webapps/cms/WEB-INF/lib/velocity-tools-struts-0.8.jar
java    3499      7170 588162
/var/lib/tomcat5/webapps/cms/WEB-INF/lib/velocity-tools-library-0.2.jar
java    3499    342710 588161
/var/lib/tomcat5/webapps/cms/WEB-INF/lib/velocity-1.3-dev.jar
java    3499    211006 588158
/var/lib/tomcat5/webapps/cms/WEB-INF/lib/postgresql.jar
java    3499    127118 588157
/var/lib/tomcat5/webapps/cms/WEB-INF/lib/jdom-b8.jar
java    3499    696431 588156
/var/lib/tomcat5/webapps/cms/WEB-INF/lib/iText.jar
java    3499    445345 588155
/var/lib/tomcat5/webapps/cms/WEB-INF/lib/dom4j.jar
java    3499    330459 588160
/var/lib/tomcat5/webapps/cms/WEB-INF/lib/struts.jar
java    3499     58798 588154
/var/lib/tomcat5/webapps/cms/WEB-INF/lib/commons-collections.jar
java    3499     22379 539885
/var/lib/tomcat5/server/webapps/manager/WEB-INF/lib/commons-fileupload-1.0.jar
java    3499     47158 539884
/var/lib/tomcat5/server/webapps/manager/WEB-INF/lib/catalina-manager.jar
java    3499      4920 539910
/var/lib/tomcat5/webapps/ROOT/WEB-INF/lib/catalina-root.jar
java    3499    946864 555039
/var/lib/tomcat5/webapps/opencms/WEB-INF/logs/opencms.log
java    3499      9830 588166
/var/lib/tomcat5/webapps/cms/WEB-INF/properties/cms.properties

After the stop the situation is this:

[root ~]# lsof -p 3499 | grep webapps
java    3499    330459 588160
/var/lib/tomcat5/webapps/cms/WEB-INF/lib/struts.jar
java    3499     22379 539885
/var/lib/tomcat5/server/webapps/manager/WEB-INF/lib/commons-fileupload-1.0.jar
java    3499     47158 539884
/var/lib/tomcat5/server/webapps/manager/WEB-INF/lib/catalina-manager.jar
java    3499      4920 539910
/var/lib/tomcat5/webapps/ROOT/WEB-INF/lib/catalina-root.jar
java    3499    946864 555039
/var/lib/tomcat5/webapps/opencms/WEB-INF/logs/opencms.log
java    3499      9830 588166
/var/lib/tomcat5/webapps/cms/WEB-INF/properties/cms.properties

Some files of webapps cms is open also if the webapps is stopped.
I would like move the webapps on shared disk on cluster, so I can umount the
disk of webapps e remount on another node and start the webapps on another
tomcat. 
When there are files open on filesystem the umount fails.
Can I force the close of the file on Tomcat when the webapps is stopped?

Thanks very much for the help
Giovanni



       
____________________________________________________________________________________
Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
http://farechase.yahoo.com/

---------------------------------------------------------------------
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


RE: Tomcat not close file when webapps is stopped

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Christopher Schultz [mailto:chris@christopherschultz.net] 
> Subject: Re: Tomcat not close file when webapps is stopped
> 
> I'm guessing that Giovanni isn't explicitly opening 
> struts.jar from his own WEB-INF/lib directory

Good point - I was thinking more of the .log and .properties files.

> Is there any reason that Tomcat (or the JVM, probably) would leave
> a JAR file open like that?

JAR files are normally the responsibility of the classloader; I'm not
familiar enough with struts to know if it has it's own classloader or is
making use of the one for the webapp.

JAR files usually are left open until the associated classloader is
garbage collected and references to the JarFile object disappear; at
that point, the finalizer() is invoked to close the file.  However,
Tomcat's WebappClassLoader does contain a stop() method, which does go
through and close all the JAR files it has opened.  There's also a
closeJARs() method, which is called periodically to close JAR files that
haven't been accessed for a while.

Since the application was stopped, I would expect the
WebappClassLoader.stop() method to have been called, thereby releasing
Tomcat's use of the struts.jar file.  Consequently, I still suspect that
either a separate classloader is involved, or some non-class resource
has been accessed from the JAR file, and that hasn't been closed.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
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


Re: Tomcat not close file when webapps is stopped

Posted by Giovanni <gi...@yahoo.com>.
--- Christopher Schultz <ch...@christopherschultz.net> wrote:

> Caldarale, Charles R wrote:
> >> From: Giovanni [mailto:giovanni.nervi@yahoo.com] 
> >> Subject: Tomcat not close file when webapps is stopped
> > 
> >> Can I force the close of the file on Tomcat when the webapps 
> >> is stopped?
> > 
> > It's not Tomcat's responsibility to clean up resources that it has no
> > knowledge of - that's up to the webapp.  You should be able to use a
> > ServletContextListener to accomplish that.  See section 10 of the
> > Servlet Spec.
> 
> Giovanni: you might want to ask the authors of the CMS application you
> are using (OpenCMS?) if anyone has observed anything like this before.
> I'm pretty sure that Struts doesn't open its own library for any reason
> (and keep it open), but you could also ask on the Struts list if anyone
 

For OpenCMS only the log file remaining open. I have 2 webapps with same
problem my cms and OpenCMS. The problem there is also in others webapps. It's
very difficult tell to all developers which the their webapps are bugged
because they not release the resource. So I thought if tomcat can force it.

> has observed that behavior before. You might also want to just wait...
> Java doesn't always clean everything up at once. Give your JVM a few
> minutes and take another look. Otherwise, break out a memory profiler
> and start poking around.

I await threee minuts but nothing the file remaining open.

JMX can help me? Or is it only for monitoring?



       
____________________________________________________________________________________
Choose the right car based on your needs.  Check out Yahoo! Autos new Car Finder tool.
http://autos.yahoo.com/carfinder/

---------------------------------------------------------------------
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


Re: Tomcat not close file when webapps is stopped

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chuck,

Caldarale, Charles R wrote:
>> From: Giovanni [mailto:giovanni.nervi@yahoo.com] 
>> Subject: Tomcat not close file when webapps is stopped
> 
>> Can I force the close of the file on Tomcat when the webapps 
>> is stopped?
> 
> It's not Tomcat's responsibility to clean up resources that it has no
> knowledge of - that's up to the webapp.  You should be able to use a
> ServletContextListener to accomplish that.  See section 10 of the
> Servlet Spec.

I'm guessing that Giovanni isn't explicitly opening struts.jar from his
own WEB-INF/lib directory and leaving it open (though it's certainly not
impossible).

Obviously, the only "cms" files still open after the webapp was shut
down were the aforementioned library and a properties file (which /was/
probably never closed).

Is there any reason that Tomcat (or the JVM, probably) would leave
a JAR file open like that?

Giovanni: you might want to ask the authors of the CMS application you
are using (OpenCMS?) if anyone has observed anything like this before.
I'm pretty sure that Struts doesn't open its own library for any reason
(and keep it open), but you could also ask on the Struts list if anyone
has observed that behavior before. You might also want to just wait...
Java doesn't always clean everything up at once. Give your JVM a few
minutes and take another look. Otherwise, break out a memory profiler
and start poking around.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGe/Qs9CaO5/Lv0PARAgt/AKCd06BKqML9ddR61mI4cZIA7EIgQQCeLVnx
2v6Eip67biybzjwHCBv9Vg8=
=JBaI
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
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


RE: Tomcat not close file when webapps is stopped

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Giovanni [mailto:giovanni.nervi@yahoo.com] 
> Subject: Tomcat not close file when webapps is stopped

> Can I force the close of the file on Tomcat when the webapps 
> is stopped?

It's not Tomcat's responsibility to clean up resources that it has no
knowledge of - that's up to the webapp.  You should be able to use a
ServletContextListener to accomplish that.  See section 10 of the
Servlet Spec.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
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