English 中文(简体)
Tomcat 6 | What s the significance of antiResourceLocking & antiJARLocking?
原标题:

I am working on a project where we ll be using Tomcat 6.0.20 for Development and production.

I came across some issues related to hot deployment which requires one to set Context.antiResourceLocking to false in server.xml. I had some questions on antiResourceLocking and antiJARLocking. I have gone through the reference at http://tomcat.apache.org/tomcat-6.0-doc/config/context.html.

What I can t understand is what exactly do you mean by a JAR getting locked or a resource getting locked. What I have read so far is that the locking problem usually comes when you are undeploying an application which fails due to a process having a lock on the file/jar. Can someone please point me to anything where I can read more on this issue?

My questions are: 1) If I set antiJARLocking and/or antiResourceLocking to false what are the problems that I can get? Can some one please provide an example? 2) Is it a bad practice to set these attributes to false in a production environment? 2) Is it true that locking won t occur on a Linux box as frequently as it can happen on a Windows box?

Appreciate your help.

Thank you.

Govind N.

问题回答

Here are my answers to these:

1) From what I can tell, setting antiJARLocking and/or antiResourceLocking to false could only cause problems on Windows (though I vaguely remember a Tomcat developer claiming that it also affects Linux -- I m disregarding that because I have seen zero evidence of it, and no examples / detailed explanations proving it).

2) It is only bad practice to set these to false when Tomcat is running on Windows.

Second 2)!! I have been running Tomcat on multiple Linux distributions and versions for more than ten years. I have never once seen a jar locking or resource locking problem due to not setting one of those attributes to true. As far as I know, it doesn t happen, but it might depend on the filesystem implementation you re using, and I always either used EXT2, EXT3, or EXT4.

If you still have questions about this, ask about it on the Tomcat-user mailing list.

Cheers!

Jason Brittain Co-author, Tomcat: The Definitive Guide (O Reilly)

1) I had built a system around svn to automatically build and deploy a webapp, the deployment was made via the Tomcat ant tasks, and with antiJARLocking and/or antiResourceLocking to false the application was not undeployed properly, because tomcat could not delete some jars and the log4j.properties config file, thus the deploy failed. So I had to set these properties to true, and tomcat did a copy of the webapp in the temp dir. This makes the deployment slower and with nearly each redeploy the temp dir grew in size, so I had to make a procedure to delete older deployments of my app from the temp dir. It is safe to delete deployments from the temp dir at any time, because tomcat will redeploy the app to the temp dir.

2) From the tomcat docs I understood that the problems with jar locking or resource locking occur only on Windows. I wouldn t set these properties to true in a production environment, because there s no need to redeploy so often, and with java it s always a good idea to do a server restart after redeploy in production (an OutOfMemoryError is always lurking in the dark, even if your own code doesn t leak). Another minor issue is that the app being deployed to the temp dir, if you modify a jsp or another file in the webapps dir, it won t be redeployed unless you copy the changes to the temp dir also.





相关问题
MySQL like query runs extremly slow for 5000 records table

I have this issue on our production server. The application stack is, Java Web App on Tomcat 6.0.18 iBatis data access layer MySQL 5.0 database CentOS The system is deployed on virtual server having ...

Set the path of web app in META-INF/context.xml?

I m tryin to change the path of a deployed war file in Tomcat. Reading the documentation I can t figure out if this is possible without moving the context-file to the /conf directory. Is it possible ...

MySQL Connector/J Problem

So I ve been having issues with the MySQL Connector/J driver not correctly loading in a Java Web Start application that is running on Tomcat 6.0.20. I ve copied the MySQL connector JAR file into the ...

Can t connect to MySQL database from tomcat

Hey, I m getting this error: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up. I m just ...

JNDI Names -- Is Prefix "jdbc/" needed?

What s up with JNDI names? I m trying to get a javax.sql.DataSource using the new annotations feature of Java 5. It s not working for me, so I want to ask... I have a in my web.xml, inside of it is ...

热门标签