Spring 在 tomcat 8.5 el-api 错误上迁移 4.3 到 5

Spring migration 4.3 to 5 on tomcat 8.5 el-api error

在 tomcat 8.5 上使用 Spring 引导初始化程序将我们的 Spring 4.3 升级到 5 时,我们开始出现异常:

2021-06-06 12:37:50,482 DEBUG [background-preinit] messageinterpolation.ResourceBundleMessageInterpolator (ResourceBundleMessageInterpolator.java:220) - Failed to load expression factory via classloader ParallelWebappClassLoader
  context: ROOT
  delegate: false
----------> Parent Classloader:
java.net.URLClassLoader@76f856a8

javax.el.ELException: Unable to find ExpressionFactory of type [# Licensed to the Apache Software Foundation (ASF) under one or more]
        at javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:154) ~[el-api.jar:3.0.FR]
        at javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:93) ~[el-api.jar:3.0.FR]
        at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.canLoadExpressionFactory(ResourceBundleMessageInterpolator.java:216) [hibernate-validator-6.2.0.Final.jar:6.2.0.Final]
        at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.buildExpressionFactory(ResourceBundleMessageInterpolator.java:170) [hibernate-validator-6.2.0.Final.jar:6.2.0.Final]
        at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.<init>(ResourceBundleMessageInterpolator.java:94) [hibernate-validator-6.2.0.Final.jar:6.2.0.Final]
        at org.hibernate.validator.internal.engine.AbstractConfigurationImpl.getDefaultMessageInterpolator(AbstractConfigurationImpl.java:573) [hibernate-validator-6.2.0.Final.jar:6.2.0.Final]
        at org.hibernate.validator.internal.engine.AbstractConfigurationImpl.getDefaultMessageInterpolatorConfiguredWithClassLoader(AbstractConfigurationImpl.java:822) [hibernate-validator-6.2.0.Final.jar:6.2.0.Final]
        at org.hibernate.validator.internal.engine.AbstractConfigurationImpl.getMessageInterpolator(AbstractConfigurationImpl.java:483) [hibernate-validator-6.2.0.Final.jar:6.2.0.Final]
        at org.hibernate.validator.internal.engine.ValidatorFactoryImpl.<init>(ValidatorFactoryImpl.java:153) [hibernate-validator-6.2.0.Final.jar:6.2.0.Final]
        at org.hibernate.validator.HibernateValidator.buildValidatorFactory(HibernateValidator.java:38) [hibernate-validator-6.2.0.Final.jar:6.2.0.Final]
        at org.hibernate.validator.internal.engine.AbstractConfigurationImpl.buildValidatorFactory(AbstractConfigurationImpl.java:451) [hibernate-validator-6.2.0.Final.jar:6.2.0.Final]
        at org.springframework.boot.autoconfigure.BackgroundPreinitializer$ValidationInitializer.run(BackgroundPreinitializer.java:149) [spring-boot-autoconfigure-2.5.0.jar:2.5.0]
        at org.springframework.boot.autoconfigure.BackgroundPreinitializer.runSafely(BackgroundPreinitializer.java:111) [spring-boot-autoconfigure-2.5.0.jar:2.5.0]
        at org.springframework.boot.autoconfigure.BackgroundPreinitializer.run(BackgroundPreinitializer.java:102) [spring-boot-autoconfigure-2.5.0.jar:2.5.0]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_151]
Caused by: java.lang.ClassNotFoundException: # Licensed to the Apache Software Foundation (ASF) under one or more
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1358) ~[catalina.jar:8.5.50]
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1180) ~[catalina.jar:8.5.50]
        at javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:147) ~[el-api.jar:3.0.FR]
        ... 14 more

el-api jar 取自 tomcat/lib,我们还将 el-api 版本从 2 更改为 3,但仍然抛出异常

是否有针对此异常的已知解决方案?

可以忽略吗?

我发现related bug它不会修复

EPEL el6 changed to end-of-life (EOL) status on 2020-11-30. EPEL el6 is no longer maintained, which means that it will not receive any further security or bug fix updates. As a result we are closing this bug.

您偶然发现错误 64097META-INF/services/javax.el.ExpressionFactory 文件中的注释未被跳过,因此出现了奇怪的错误。

此问题已在 Tomcat 版本 8.5.51 and 9.0.31 中修复。