Tomcat's embedded feature unable to scan jars in classloader hierarchy

Embedded tomcat giving failed to scan jars from classloader hierarchy

Solution 1:

One option is to include server.tomcat.additional-tld-skip-patterns=*.jar within the application.properties file, while another option is to include server: tomcat: additional-tld-skip-patterns: '*.jar'within the application.yml file.
The component known as "Jar Scanner" and the response given by the official source are being referred to.

Solution 2:

The dependency hierarchy does not suggest that xml-apis.jar is required by tomcat-embed-core, so it should not be assumed.
To fix the error, ensure that the scope of the xml-apis.jar is not set to "provided". Next, delete all the files located under C:/Users/raghavender.n/.m2/repository/xalan/xalan/ and run "mvn clean install". Finally, verify if the xml-apis.jar is present.
If you are searching for information on Spring Web Application that utilizes an embedded Tomcat but does not employ Spring Boot, you can find helpful insights in this post.

Solution 3:

To find a solution, add the subsequent line to the catalina.properties file.
tomcat.util.scan.StandardJarScanFilter.jarsToSkip=*.jar
Java - shared classloader with embedded Tomcat 8, 2 You could try using the setDelegate method in StandardContext to prevent the web-app classloader from reloading the Counter class, but this impacts security in a bad manner so I advice against that. The usual way to expose statistics is to use JMX (MBeans). You enable this by calling the setUseNaming method in …

Java.io.FileNotFoundException: /tomcat/lib/webservices-api.jar

Solution 1:

Starting from Tomcat 8.0.38, there is a flag named scanManifest that allows scanning additional classpath entries from jars' MANIFEST.MF file. The default is set to true, meaning that the manifest of jars is scanned. To avoid issues, it is recommended to verify whether you have any jar that refers to this jar file using the CLASS-PATH entry in the MANIFEST.MF. I faced a similar issue before.

May 07, 2019 11:33:21 AM org.apache.tomcat.util.scan.StandardJarScanner processURLs
WARNING: Failed to scan [file:/C:/apache-tomcat-9.0.8/lib/jaxws-api.jar] from classloader hierarchy
java.io.FileNotFoundException: C:\apache-tomcat-9.0.8\lib\jaxws-api.jar (The system cannot find the file specified)

I noticed that my jar file named jaxws-rt-2.1.3 has jaxws-api.jar included in its class path. However, since I already have jaxws-api-2.1.jar in my lib, the jarscanner raised an error of "File not found" because it was searching for a versionless file.
By including the given entry in context.xml located under TOMCAT_HOME/conf, the issue of resolving non-existent jar files can be resolved.

Another way to deploy the application is by rectifying the manifest file to comprise the jar version.

Solution 2:

The implementation of the given specification is present in webservices-rt-xxx.jar and it should be noted that it is different from webservices-api.jar .

It is recommended to add the second jar to your lib directory as well.

Java.io.FileNotFoundException: /tomcat/lib/webservices, In Tomcat 8.0.38 and onwards we have one flag called scanManifest to scan the additional classpath entries from the MANIFEST.MF of the jars. The default is true i.e. to scan the manifest of jars.

Check if you have any jar with CLASS-PATH entry in MANIEST.MF referring this jar file. I got the similar issue Code sampleMay 07, 2019 11:33:21 AM org.apache.tomcat.util.scan.StandardJarScanner processURLs

WARNING: Failed to scan [file:/C:/apache-tomcat-9.0.8/lib/jaxws-api.jar] from classloader hierarchyjava.io.FileNotFoundException: C:\apache-tomcat-9.0.8\lib\jaxws-api.jar (The system cannot find the file specified)Feedback

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

Solution 1:

RootCause:
According to the Tomcat Wiki, during server startup, the Servlet 3.0 specification mandates the scanning of Jars.

For this intention, Tomcat is employing the StandardJarScanner from org.apache.tomcat.util.scan.

From the documentation of the class called StandardJarScanner.

The JarScanner implementation, by default, examines the contents of the WEB-INF/lib directory, followed by the classloader provided. After that, it traverses up the classloader hierarchy. This approach fulfills the requirements of the Servlet 3.0 specification and includes various Tomcat-specific extensions. These extensions are as follows:
By default, the classloader hierarchy is scanned, while checking all files for JARs is not enabled.
By default, the feature that tests for exploded JARs in all directories is disabled.
The configuration controls all of the available extensions.

  • Option 1: Tailored for Spring Boot.

It is possible to turn off the scanning of this jar.

To disable it, I included a property in the application-xxx.properties file that is specific to Spring Boot.

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

Tomcat offers comparable properties that can be found at this location.

The aforementioned attributes can be employed to set up traditional Tomcat applications that are not based on Spring Boot.

  • Alternative 2: Tailored for Spring Framework

As a solution, you can turn off the JarScanner specifically for manifest files.

@Bean
public EmbeddedServletContainerFactory embeddedServletContainerFactory() {
  return new TomcatEmbeddedServletContainerFactory() {
    @Override
    protected void postProcessContext(Context context) {
      ((StandardJarScanner) context.getJarScanner()).setScanManifest(false);
    }
  };
}
  • Option 3: Conventional Independent Tomcat.

...

...

The component being referred to is the Jar Scanner.

Solution 2:

To enhance Sundaraj's discoveries, it is not recommended to entirely turn off TLD scanning as it might cause a disruption in the support of JSP/JSTL.

The problem lies in the fact that although the classpath is fine, Tomcat examines the manifest files of each Jar. This causes meaningless paths to be generated when using Maven because every Jar is located in its own directory, which is likely to occur when running from Eclipse.

To continue using JSP alongside JSTL, it is recommended to only deactivate the scanning of the manifest.

To configure your application for Spring Boot 2.0, include the following in your application's settings.

  @Bean
  public TomcatServletWebServerFactory tomcatFactory() {
    return new TomcatServletWebServerFactory() {
      @Override
      protected void postProcessContext(Context context) {
        ((StandardJarScanner) context.getJarScanner()).setScanManifest(false);
      }
    };
  }

Solution 3:

We must configure the StandardJarScanner loaded by JarScannerFactory in order to ensure compatibility with spring boot 2.1.8.

import org.apache.tomcat.JarScanner;
import org.apache.tomcat.util.scan.StandardJarScanner;
import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class WebContextConfiguration {
    @Bean
    public ServletContextInitializer servletContextInitializer() {
        return context -> context.setAttribute(
                JarScanner.class.getName(),
                new StandardJarScanner() {{
                    setScanManifest(false);
                }}
        );
    }
}

Tomcat8 - Resource locking in embedded tomcat, I don't find any method for this. I use embedded tomcat 8.5.8. Stack Overflow. About; Products For Teams; Stack Overflow Tomcat 8 throwing - org.apache.catalina.webresources.Cache.getResource Unable to add the resource Invalid character found in method name. HTTP method names must be …

Which of the following method is called immediately after the re-render

component did update arguments

componentDidUpdate(prevProps, prevState) {
  // only update chart if the data has changed
  if (prevProps.data !== this.props.data) {
    this.chart = c3.load({
      data: this.props.data
    });
  }
}

lifecycles if reactjs

class Clock extends React.Component {
  constructor(props) {
    super(props);
    this.state = {date: new Date()};
  }
  componentDidMount() {  }
  componentWillUnmount() {  }
  render() {
    return (
      

        
Hello, world!

        
It is {this.state.date.toLocaleTimeString()}.

      

    );
  }
}

AFTER upgrade from Spring boot 1.2 to 1.5.2, Testing all directories to see if they are exploded JARs (disabled by default) All of the extensions may be controlled via configuration. Solution1: Spring Boot specific. We can disablethis jar scanning. I disabled it by adding below property in application-xxx.properties file. This property is Spring Boot specific.

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 200,176评论 5 469
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 84,190评论 2 377
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 147,232评论 0 332
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 53,953评论 1 272
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 62,879评论 5 360
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,177评论 1 277
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,626评论 3 390
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,295评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,436评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,365评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,414评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,096评论 3 315
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,685评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,771评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,987评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,438评论 2 346
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,032评论 2 341

推荐阅读更多精彩内容