从 Tomcat 8.0.39 升级到 8.0.41 导致“无法扫描"错误 [英] Upgrade from Tomcat 8.0.39 to 8.0.41 results in 'failed to scan' errors

查看:44
本文介绍了从 Tomcat 8.0.39 升级到 8.0.41 导致“无法扫描"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Spring Boot WAR 应用程序,可以在 AWS 上的 Tomcat 8.0.39 下完美运行.发出sudo service tomcat8 stop,通过sudo yum update升级到Tomcat 8.0.41,重启实例后,应用没有启动.在 catalina 日志文件中,我看到了大量以下类型的异常:

I have a Spring Boot WAR application perfectly working under Tomcat 8.0.39 on AWS. After issuing sudo service tomcat8 stop, upgrading to Tomcat 8.0.41 through sudo yum update, and rebooting the instance, the application does not start. In the catalina log file, I see a ton of exceptions of the type:

19-Feb-2017 10:27:15.326 WARNING [localhost-startStop-1] org.apache.tomcat.util.
scan.StandardJarScanner.scan Failed to scan [file:/usr/share/java/tomcat8/javax.
annotation-api.jar] from classloader hierarchy
 java.io.FileNotFoundException: /usr/share/java/tomcat8/javax.annotation-api.jar
 (No such file or directory)

以下是 Tomcat 抱怨的文件:

Here are the files Tomcat complains about:

javax.annotation-api.jar
jsr181-api.jar
jaxb-api.jar
javax.xml.soap-api.jar
FastInfoset.jar
mimepull.jar
saaj-impl.jar
stax2-api.jar
woodstox-core-asl.jar
jaxb-core-2.2.10-b140802.1033.jar
jaxb-api-2.2.12-b140109.1041.jar
istack-commons-runtime-2.19.jar
txw2-2.2.10-b140802.1033.jar
hk2-core.jar
class-model.jar
config.jar
auto-depends.jar
javax.inject.jar
hk2-api.jar
osgi-resource-locator.jar
tiger-types.jar
bean-validator.jar
jtype.jar

关于如何解决这个问题有什么建议吗?

Any suggestions on how to fix this?

更新 #1:

以上部分文件属于jaxws-ri.结果是,我将 JAX-WS RI 2.2.10 lib 目录中的一些 (10),但不是全部 (23) 个 jars 复制到 Tomcat 的 lib 目录中.复制丢失的13个jar后,Tomcat在catalina日志文件中抱怨的文件列表已经缩小到:

Some of the above files belong to jaxws-ri. It turned out that I had some (10), but not all (23), of the jars from JAX-WS RI 2.2.10 lib directory copied into Tomcat's lib directory. After copying the missing 13 jars, the list of files Tomcat complains about in the catalina log file has shrunk to:

jaxb-core-2.2.10-b140802.1033.jar
jaxb-api-2.2.12-b140109.1041.jar
istack-commons-runtime-2.19.jar
txw2-2.2.10-b140802.1033.jar
hk2-core.jar
class-model.jar
config.jar
auto-depends.jar
javax.inject.jar
hk2-api.jar
osgi-resource-locator.jar
tiger-types.jar
bean-validator.jar
jtype.jar

(上述文件的异常在日志文件中重复多次.看起来扫描器在启动时被重复调用,可能扫描不同的类路径.)

(Exceptions for the above files are repeated several times in the log file. Looks like the scanner is invoked repeatedly at startup, perhaps scanning different class paths.)

这告诉我,随着从 8.0.39 到 8.0.41 的过渡,Tomcat 突然对所有引用的 jar 的存在变得非常挑剔,即使应用程序在没有很多引用的情况下也能正常工作.此外,Tomcat 似乎对某些 jar 的特定构建非常讲究(例如,请参阅上面的 jaxb-core...jaxb-api... jar).

This tells me that with the transition from 8.0.39 to 8.0.41, Tomcat suddenly became very picky about the presence of all referenced jars, even though the application works perfectly fine without many of them. In addition, Tomcat appears to be very particular about specific builds of some jars (e.g. see the jaxb-core... and jaxb-api... jars above).

现在,为了解决这个问题,我可以尝试找到所有这些丢失的 jar 并将它们复制到 Tomcat 的 lib 目录.但是,由于通用名称(例如 config.jar)或缺少版本号,我无法确保其中一些文件的来源正确.

Now, to fix this I could try to find all these missing jars and copy them to Tomcat's lib directory. However, I see no way of assuring the proper source for some of them due to generic names, such as config.jar, or missing version numbers.

那么,有没有办法防止 Tomcat 的 scan.StandardJarScanner.scan 对所有这些罐子如此挑剔?

So, is there a way to prevent Tomcat's scan.StandardJarScanner.scan from being so picky about all these jars?

更新 #2:

原来在Tomcat 8.0.38中,添加了一个设置来控制jar扫描,其值默认为true.要关闭扫描,请在 context.xml 中添加以下行:

It turns out that in Tomcat 8.0.38, a setting was added to control jar scanning, the value of which defaults to true. To turn scanning off, add the following line in context.xml:

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

详情见提供一个选项来禁用处理 jar 清单文件中的类路径条目.

推荐答案

有一个错误,即 Tomcat 8 忽略了 MANIFEST.MF JAR 文件,参见 错误 59226:

There was a bug, that Tomcat 8 ignores the Class-Path header in the MANIFEST.MF file of a JAR, see Bug 59226:

错误 59226 - StandardJarScanner 忽略清单类路径标头中的 jar

Bug 59226 - StandardJarScanner ignores jars in manifest Class-path header

这个错误在 Tomcat 8.0.34 中得到了修复,但它对不需要的 JAR 产生了很多警告,参见 错误 59961:

This bug was fixed with Tomcat 8.0.34, but it produced a lot of warnings for not required JARs, see Bug 59961:

错误 59961 - 提供一个选项来禁用处理 jar 清单文件中的类路径条目

Bug 59961 - Provide an option to disable processing of Class-Path entry in a jar's manifest file

自 Tomcat 8.0.38 起,您可以禁用对 MANIFEST.MF 文件的扫描,请参阅 Jar 扫描器组件:

Since Tomcat 8.0.38 you can disable the scan of the MANIFEST.MF file, see The Jar Scanner Component:

扫描清单

如果为 true,则将扫描找到的任何 JAR 的清单文件以查找其他类路径,并将这些条目添加到要扫描的 URL 中.默认为真.

If true, the Manifest files of any JARs found will be scanned for additional class path entires and those entries will be added to the URLs to scan. The default is true.

这篇关于从 Tomcat 8.0.39 升级到 8.0.41 导致“无法扫描"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆