How to disable Tomcat JARScanner
Solution 1
You should add the JarScanner element as a child of the root Context element in the context.xml file.
I have this kind of META-INF/context.xml file in the war file for disabling the JarScanner:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<JarScanner scanClassPath="false" scanAllFiles="false" scanAllDirectories="false"/>
</Context>
Solution 2
you can disable the JarScanner globally for user-definted patterns by opeining the file at
%TOMCAT_HOME%/conf/catalina.properties
and add a filename pattern to tomcat.util.scan.StandardJarScanFilter.jarsToSkip
list.
For example, if you want to disable jar scanning completely you could add:
tomcat.util.scan.StandardJarScanFilter.jarsToSkip=\
*.jar,\
NOTE: this may of course lead to issues if you're employing JSTL, as templates won't be found by the scanner
Gonzalo Gallotti
Updated on June 05, 2022Comments
-
Gonzalo Gallotti almost 2 years
How: To disable Tomcat JARScanner?
Why: To stop Tomcat scan every .jar in my LIB folder.According to documentation it says that it is possible to disable it within context.xml. But it seems to not be working. (May be I am missing something) I made an exhaustive search in forums and could not find the solution.
This is in context.xml (not working yet):
<JarScanner scanClassPath="false" scanAllFiles="false" scanAllDirectories="false"></JarScanner>
Thanks in advance.
-
Christopher Schultz almost 12 yearsPlease post your attempted configuration. It's hard to guess why it's not working when you don't post what you've tried.
-
Gonzalo Gallotti over 11 yearsI've added the line i'am using in context.xml. Sorry and thanks
-
Christopher Schultz over 11 yearsDo you want to disable scanning of all JAR files entirely? You have no
.tld
files that need to be auto-discovered and you don't use any annotations? -
Gonzalo Gallotti over 11 yearsI removed the entry from web.xml and the issue stoped. Still wanting to disable JarScanner from Context.xml (for prototyiping purposes)
-
-
Stephen Ostermiller over 6 yearsIs that the global context.xml file located at
/etc/tomcat8/context.xml
? Can jar scanning be disabled on a web-app by web-app basis by instead placing the configuration in your web app's war file inWEB-INF/web.xml
? -
Talijanac about 6 yearsIt can be disabled on web-app by bassis by using application META-INF/context.xml file