Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is antiJARLocking attribute?

what does the attribute antiJARLocking mean ? What is it's significance when I turn it to true / false ?

I have seen this attribute in context.xml file of web-application :

<?xml version="1.0" encoding="UTF-8"?> <Context antiJARLocking="true" path="/poll">  <Resource name="jdbc/PollDatasource" auth="Container"            type="javax.sql.DataSource"  // etc etc </context> 
like image 276
Suhail Gupta Avatar asked Jul 23 '12 05:07

Suhail Gupta


2 Answers

Tomcat 7

From the Tomcat 7.0 documentation for Context Configuration:

"antiJARLocking - If true, the Tomcat classloader will take extra measures to avoid JAR file locking when resources are accessed inside JARs through URLs. This will impact startup time of applications, but could prove to be useful on platforms or configurations where file locking can occur. If not specified, the default value is false."

(The problem they are trying to address … I think … is that a locked JAR file will stop things like hot redeployment from working.)

Read the documentation for more information.

Tomcat 8 and later

The antiJARLocking attribute is replaced by the antiResourceLocking attribute in Tomcat 8 and later. The documentation mentions some noteworthy side-effects of setting this attribute.


See also:

  • http://stackoverflow.com/q/22480442/642706 ... which notes that turning on this feature may be enabling a permgen (or in Java 8+ a metaspace) memory leak if you perform hot redeploys.
like image 195
Stephen C Avatar answered Oct 04 '22 00:10

Stephen C


Windows likes to lock files during classloading, thus preventing them from being manually deleted or being opened by another application. It also causes problems when undeploying and redeploying a war. In Tomcat, when you specify <Context antiJARLocking="true"/> this will prevent Windows from acquiring a lock on your jars

like image 31
cosbor11 Avatar answered Oct 04 '22 00:10

cosbor11