Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable scanManifest of Jar Scan in tomcat embed in spring boot

I'm getting some warnings in log, like this:

java.io.FileNotFoundException: C:\Users\user\.m2\repository\com\lowagie\itext\2.0.8\bcmail-jdk14-138.jar (O sistema não pode encontrar o arquivo especificado)
    at java.util.zip.ZipFile.open(Native Method) ~[na:1.8.0_121]
    at java.util.zip.ZipFile.<init>(ZipFile.java:219) ~[na:1.8.0_121]
    at java.util.zip.ZipFile.<init>(ZipFile.java:149) ~[na:1.8.0_121]
    at java.util.jar.JarFile.<init>(JarFile.java:166) ~[na:1.8.0_121]
    at java.util.jar.JarFile.<init>(JarFile.java:130) ~[na:1.8.0_121]
    at org.apache.tomcat.util.scan.JarFileUrlJar.<init>(JarFileUrlJar.java:60) ~[tomcat-embed-core-8.5.6.jar:8.5.6]
    at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:48) ~[tomcat-embed-core-8.5.6.jar:8.5.6]
    at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:338) ~[tomcat-embed-core-8.5.6.jar:8.5.6]
    at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:288) ~[tomcat-embed-core-8.5.6.jar:8.5.6]
    at org.apache.jasper.servlet.TldScanner.scanJars(TldScanner.java:262) [tomcat-embed-jasper-8.5.6.jar:8.5.6]
    at org.apache.jasper.servlet.TldScanner.scan(TldScanner.java:104) [tomcat-embed-jasper-8.5.6.jar:8.5.6]
    at org.apache.jasper.servlet.JasperInitializer.onStartup(JasperInitializer.java:101) [tomcat-embed-jasper-8.5.6.jar:8.5.6]
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5178) [tomcat-embed-core-8.5.6.jar:8.5.6]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.6.jar:8.5.6]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403) [tomcat-embed-core-8.5.6.jar:8.5.6]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393) [tomcat-embed-core-8.5.6.jar:8.5.6]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_121]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_121]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_121]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]

In a standalone tomcat I can create a context.xml with:

<Context>
  ...
  <JarScanner scanManifest="false"/>
  ...
</Context>

How can I disable the JarScanner for manifest files (https://tomcat.apache.org/tomcat-8.0-doc/config/jar-scanner.html) in a java configuration class using Spring Boot.

like image 210
Beto Neto Avatar asked Apr 12 '17 13:04

Beto Neto


People also ask

How do you exclude a Tomcat related jars from spring boot starter web?

If we want to exclude tomcat from spring boot, we don't need to do much, we just need to add one additional block(<exclusions>) to the Spring Boot dependency. <exclusions> tag is used to make us sure that given server/artifactId is being removed at the time of build.

What is TLD scanning in Tomcat?

On startup, Tomcat recursively scans the WEB-INF directories for TLD (Tag Library Descriptor) files. As a result, if a webapp has a lot of files under that directory, it slows down the startup process.

Why we use Tomcat embed Jasper in spring boot?

Anyway, the tomcat-embed-jasper is marked as provided , so indicates that you expect the JDK or a container to provide the dependency at runtime. This scope is only available on the compilation and test classpath, and is not transitive.

Can we configure embedded Tomcat server in spring boot?

Overview. Spring Boot ships with an Embedded Tomcat Server. When we run a Spring Boot Application, the embedded tomcat server is started and the application is launched inside the server. The Embedded tomcat server has a set of default configurations, which makes them ready to use.


1 Answers

This is controllable via a property now:

# Comma-separated list of additional patterns that match jars to ignore for TLD scanning.    
server.tomcat.additional-tld-skip-patterns=*.jar

via AFTER upgrade from Spring boot 1.2 to 1.5.2, FileNotFoundException during Tomcat 8.5 Startup

like image 65
checketts Avatar answered Sep 21 '22 15:09

checketts