Fixing Tomcat Slow startup with custom jar files inside Tomcat/lib directory.
Many a times, we come across some scenarios wherein there is a need to add certain jar files inside Tomcat/lib directory.
This case also arises when we are introducing a Servlet Filter in our web-app. And some external classes/ libraries are referred. In such scenarios, it is required that such classes are provided at Tomcat Server Startup. Mostly in the jar file.
And when you add some custom libraries inside lib folder, Tomcat Server takes more time to boot than usual. This can be frustrating for some, as it is only consuming some time.
But, this time consuming startup can be avoided.
Tomcat provides a way to skip scanning the jars mentioned in tomcat.util.scan.StandardJarScanFilter.jarsToSkip property inside catalina.properties file.
Add the custom jar that you suspect is taking more time during Tomcat startup.
The Comment mentions :
# Default list of JAR files that should not be scanned using the JarScanner
# functionality. This is typically used to scan JARs for configuration
# information. JARs that do not contain such information may be excluded from
# the scan to speed up the scanning process. This is the default list. JARs on
# this list are excluded from all scans. The list must be a comma separated list
# of JAR file names.
Make sure to add the pattern to skip the jars. Else the jar file is scanned for any configuration information, and it takes some time, hereby delaying server startup.
Do try it out, and let me know if it works.
Do drop some comments is any issues are faced.
=============== Happy Coding ===============
Comments
Post a Comment