Tomcat:At least one JAR was scanned for TLDs yet contained no TLDs

时间:2022-01-26 02:57:17

启动Tomcat的时候,经常见到这样的BUG:

 
14-Apr-2019 13:53:25.198 信息 [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them.
Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.

以前不知道怎么处理,怎么处理才是正确的,最近研究了点点Tomcat源码,也算知其一,知其二,不知其三四五六七了,下面先贴上解决方案:

解决方案:

catalina-home/conf/Catalina.properties中有这样一个属性:jarsToSkip

 
tomcat.util.scan.StandardJarScanFilter.jarsToSkip=\
bootstrap.jar,commons-daemon.jar,tomcat-juli.jar,\
annotations-api.jar,el-api.jar,jsp-api.jar,servlet-api.jar,websocket-api.jar,\
catalina.jar,catalina-ant.jar,catalina-ha.jar,catalina-storeconfig.jar,\
catalina-tribes.jar,\
jasper.jar,jasper-el.jar,ecj-*.jar,\
tomcat-api.jar,tomcat-util.jar,tomcat-util-scan.jar,tomcat-coyote.jar,\
tomcat-dbcp.jar,tomcat-jni.jar,tomcat-websocket.jar,\
tomcat-i18n-en.jar,tomcat-i18n-es.jar,tomcat-i18n-fr.jar,tomcat-i18n-ja.jar,\
tomcat-juli-adapters.jar,catalina-jmx-remote.jar,catalina-ws.jar,\
tomcat-jdbc.jar,\
tools.jar,\
commons-beanutils*.jar,commons-codec*.jar,commons-collections*.jar,\
commons-dbcp*.jar,commons-digester*.jar,commons-fileupload*.jar,\
commons-httpclient*.jar,commons-io*.jar,commons-lang*.jar,commons-logging*.jar,\
commons-math*.jar,commons-pool*.jar,\
jstl.jar,taglibs-standard-spec-*.jar,\
geronimo-spec-jaxrpc*.jar,wsdl4j*.jar,\
ant.jar,ant-junit*.jar,aspectj*.jar,jmx.jar,h2*.jar,hibernate*.jar,httpclient*.jar,\
jmx-tools.jar,jta*.jar,log4j*.jar,mail*.jar,slf4j*.jar,\
xercesImpl.jar,xmlParserAPIs.jar,xml-apis.jar,\
junit.jar,junit-*.jar,ant-launcher.jar,\
cobertura-*.jar,asm-*.jar,dom4j-*.jar,icu4j-*.jar,jaxen-*.jar,jdom-*.jar,\
jetty-*.jar,oro-*.jar,servlet-api-*.jar,tagsoup-*.jar,xmlParserAPIs-*.jar,\
xom-*.jar
 

我们只需要将上面的属性改成:

tomcat.util.scan.StandardJarScanFilter.jarsToSkip=*.jar

再次启动Tomcat,查看容器启动时候效果:发现果然没有了之前的那个提示信息.

Tomcat:At least one JAR was scanned for TLDs yet contained no TLDs

Why?

这个提示信息取消掉它出现,这是其一解决方案,其二呢?这样做会带来什么效果

可能JSP后端的动态渲染技术一定程度上会影响响应速度,如果jar包中没有tld,没有自定义tld等标签的话,我们可以放心使用上述方式。上述方式原理呢下面简单记录下:

解析上述tld代码方法位于:TldScanner#scanJars.

解析方式会按照

Tomcat:At least one JAR was scanned for TLDs yet contained no TLDs

解释说明: 会扫描该项目所有加载到的jar包,包括jre/lib下的包,遍历每个jar检测是否有tld,而Catalina.properties配置中的两个jarsToSkip和jarsToScan作用呢?

check方法中tldSkipSet就是取的jarsToSkip的值,tldScanSet取的就是jarsToSkip的值;tldSkipSet通过正则表达式匹配当前check的jar包,所有的jar都会匹配上*.jar,但是tldScanSet就不一定可以匹配上,Catalina.properties中jarsToScan都是日志相关的jar包,无法和当前正在校验的jar包正则匹配上,所有这个jar包Tomcat不会做任何扫描处理。上述方法在一定程度上提高了Tomcat启动速度,如果在当前项目加载jar包特别多的情况下提升应该明显。

public boolean check(JarScanType jarScanType, String jarName) {
Lock readLock = configurationLock.readLock();
readLock.lock();
try {
final boolean defaultScan;
final Set<String> toSkip;
final Set<String> toScan;
switch (jarScanType) {
case TLD: {
defaultScan = defaultTldScan;
toSkip = tldSkipSet;
toScan = tldScanSet;
break;
}
case PLUGGABILITY: {
defaultScan = defaultPluggabilityScan;
toSkip = pluggabilitySkipSet;
toScan = pluggabilityScanSet;
break;
}
case OTHER:
default: {
defaultScan = true;
toSkip = defaultSkipSet;
toScan = defaultScanSet;
}
}
if (defaultScan) {
if (Matcher.matchName(toSkip, jarName)) {
if (Matcher.matchName(toScan, jarName)) {
return true;
} else {
return false;
}
}
return true;
} else {
if (Matcher.matchName(toScan, jarName)) {
if (Matcher.matchName(toSkip, jarName)) {
return false;
} else {
return true;
}
}
return false;
}
} finally {
readLock.unlock();
}
}

How?

假如当前情况下使用到的jar包中有使用tld文件,我们又不想全部扫描所有jar,并且不想看到上述信息At least one JAR 出现,解决方案是:

 
tomcat.util.scan.StandardJarScanFilter.jarsToSkip=*.jar
tomcat.util.scan.StandardJarScanFilter.jarsToScan=yourjarFile.jar

总结

通过修改Catalina.properties可以提高程序启动速度,如果有使用到tld文件,再配置比较合适。

Tomcat:At least one JAR was scanned for TLDs yet contained no TLDs的更多相关文章

  1. Tomcat 8启动速度慢原因1&colon; At least one JAR was scanned for TLDs yet contained no TLDs

    最近使用tomcat8启动项目时,发现At least one JAR was scanned for TLDs yet contained no TLDs这一步加载时间非常长, 从网上收集了各种资料 ...

  2. Tomcat启动慢原因之一 At least one JAR was scanned for TLDs yet contained no TLDs

    Tomcat启动时提示: 信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging f ...

  3. &lbrack;转&rsqb;完美解决)Tomcat启动提示At least one JAR was scanned for TLDs yet contained no TLDs

    一.文章前言    本文是亲测有效解决At least one JAR was scanned for TLDs yet contained no TLDs问题,绝对不是为了积分随便粘贴复制然后压根都 ...

  4. tomcat 启动时遇到org&period;apache&period;jasper&period;servlet&period;TldScanner&period;scanJars At least one JAR was scanned for TLDs yet contained no TLDs

    当发生这样的错误的时候 org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet ...

  5. tomcat启动卡在了 At least one JAR was scanned for TLDs yet contained no TLDs 的根本原因与解决办法

    1.前言 有时候服务器开启时启动不了,卡在了 org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned fo ...

  6. tomcat启动很慢 停留在 At least one JAR was scanned for TLDs yet contained no TLDs&period;

    部署项目时候,发现启动特别慢,要等好几分钟,这不正常啊.然后每次部署都停留在 At least one JAR was scanned for TLDs yet contained no TLDs. ...

  7. 解决Tomcat7&OpenCurlyDoubleQuote;At least one JAR was scanned for TLDs yet contained no TLDs”问题

    解决Tomcat7“At least one JAR was scanned for TLDs yet contained no TLDs”问题 2013-12-05 21:58:00|  分类: t ...

  8. Tomcat7启动log打印到INFO&colon; At least one JAR was scanned for TLDs yet contained no TLDs&period;就停止不动了

    环境: RHEL7,tomcat7.0.70 问题: 启动tomcat时,catalina.out日志打印到如下内容就停止不动了,也不报错 SEVERE: FarmWarDeployer can on ...

  9. At least one JAR was scanned for TLDs yet contained no TLDs&period;

    Tomcat提示如下: At least one JAR was scanned for TLDs yet contained no TLDs. =========================== ...

随机推荐

  1. ajax普通弹窗;Bootstrp弹窗

    1.普通弹窗 主页面: <head> <meta http-equiv="Content-Type" content="text/html; chars ...

  2. QQ等级图标排名说明&lowbar;QQ等级表&comma;QQ最高等级&lpar;皇冠&rpar; qq到一星要5天

    从2007年11月29日中午12:00开始,在不改变原有计算方式的情况下,加速QQ会员等级升级.QQ会员用户在原有通过每天在线2小时累积活跃天数来获取相应QQ等级增长的基础上,还可以根据QQ会员VIP ...

  3. erlang局域网内节点通信——艰难四步曲 (转)

    http://blog.chinaunix.net/uid-22566367-id-382011.html 在Programming Erlang这本书中,在写到第十章中,主要实现的是不同节点之间的通 ...

  4. axel源码学习&lpar;1&rpar;&mdash&semi;&mdash&semi;重要流程细节

    前面一篇文章的流程太过于简单,基本没有触及到axel的核心,因此本文将要把axel中的几个重要的主要的操作流程单独弄出来看看,还是按照main函数的执行顺序来展开,略去错误处理之类的流程仅仅着眼于最重 ...

  5. 基于Android 4&period;4 开发的多窗体系统 开放源代码

    Hi, 这是我基于Android 4.4开发的多窗体系统,还有非常多不足,还请多多不吝赐教啊,代码已经所有开源. 视频地址 源代码地址 Done: 1. APP以窗体化显示 在 PhoneWindow ...

  6. RabbitMq install on Centos6&period;3

    安装服务(root) step 1:  启用EPEL:EPEL是一个Fedora Project 推出的 EPEL(Extra Packages for Enterprise Linux),EPEL是 ...

  7. 兼容IE8的input输入框的正确使用姿势

    input是一个很常见的标签,大家使用的也很常见,但是我在具体的工作中发现要想完美的使用这个标签还是任重而道远,下面是我碰到的几个问题. 1.我们在使用这个标签的时候会习惯的加上placeholder ...

  8. effective java学习笔记之不可实例化的类

    在没有显式声明一个类的构造方法时,编译器会生成默认的无参构造方法,在设计工具类时,我们通常将方法设置成静态方法,以类名.方法名的形式调用,此时这个类就没有必要创建实例,我们知道抽象类不可以被实例化,但 ...

  9. vue入坑总结

    1.Do not mount Vue to <html> or <body> - mount to normal elements instead. Vue2.x之后不推荐挂载 ...

  10. 前端技术之&lowbar;CSS详解第三天

    前端技术之_CSS详解第三天 二.权重问题深入 2.1 同一个标签,携带了多个类名,有冲突: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 ...