Servlets 带有Websphere Application Server org.apache.logging.log4j.web.Log4jServletContainerInitializer的Log4j2不是子类型

Servlets 带有Websphere Application Server org.apache.logging.log4j.web.Log4jServletContainerInitializer的Log4j2不是子类型,servlets,websphere,log4j2,Servlets,Websphere,Log4j2,我们有一个应用程序,它使用Log4j2并在WAS8.5上运行。我们选择了类加载选项作为PARENT_LAST,因此jar文件将从WEB-INF/lib中获取。我们在启动服务器时遇到以下错误 com.ibm.ws.exception.RuntimeWarning: com.ibm.ws.webcontainer.exception.WebAppNotLoadedException: Failed to load webapp: Failed to load webapp: javax.servle

我们有一个应用程序,它使用Log4j2并在WAS8.5上运行。我们选择了类加载选项作为PARENT_LAST,因此jar文件将从WEB-INF/lib中获取。我们在启动服务器时遇到以下错误

com.ibm.ws.exception.RuntimeWarning: com.ibm.ws.webcontainer.exception.WebAppNotLoadedException: Failed to load webapp: Failed to load webapp: javax.servlet.ServletContainerInitializer: Provider org.apache.logging.log4j.web.Log4jServletContainerInitializer not a subtype
    at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:432)
    at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:718)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1177)
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1370)
    at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:639)
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:968)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:776)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl$5.run(ApplicationMgrImpl.java:2195)
    at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5387)
    at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5603)
    at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2200)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:435)
    at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:378)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$500(CompositionUnitMgrImpl.java:126)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:984)
    at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:502)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1865)
Caused by: com.ibm.ws.webcontainer.exception.WebAppNotLoadedException: Failed to load webapp: Failed to load webapp: javax.servlet.ServletContainerInitializer: Provider org.apache.logging.log4j.web.Log4jServletContainerInitializer not a subtype
    at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:759)
    at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:634)
    at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:426)
    ... 18 more
Caused by: com.ibm.ws.webcontainer.exception.WebAppNotLoadedException: Failed to load webapp: javax.servlet.ServletContainerInitializer: Provider org.apache.logging.log4j.web.Log4jServletContainerInitializer not a subtype
    at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:176)
    at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:749)
    ... 20 more
Caused by: java.util.ServiceConfigurationError: javax.servlet.ServletContainerInitializer: Provider org.apache.logging.log4j.web.Log4jServletContainerInitializer not a subtype
    at java.util.ServiceLoader.fail(ServiceLoader.java:243)
    at java.util.ServiceLoader.access$300(ServiceLoader.java:193)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:381)
    at java.util.ServiceLoader$1.next(ServiceLoader.java:457)
    at com.ibm.ws.webcontainer.webapp.WebAppImpl.initializeServletContainerInitializers(WebAppImpl.java:535)
    at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:409)
    at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:88)
    at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:169)
当我们将与lo4j2相关的jar作为服务器ext文件夹的一部分时,它工作正常,没有任何问题。 我们还有log4jjar以及一些第三方jar正在使用的部分应用程序。
一些人能否解释一下这里发生了什么以及引发此错误的原因?

如果您正在使用web.xml进行应用程序配置,请参阅以下链接,以配置与log4j web模块相关的侦听器和筛选器


谢谢您的回复。我在log4j网站上添加了监听器和过滤器。但是我仍然得到了上面的错误。另外,如果我在WAS的ext文件夹中有与log4j相关的jar,并且首先使用类装入器选项作为PARENT_,那么它可以正常工作。但是我需要使用PARENT_LAST来加载我的应用程序jar的第一个。这可能是类加载器的问题。我假设您的应用程序是servlet3.0应用程序。检查类路径,确保类路径上没有servlet api,并且类路径上没有dupllcate log4j2 jar文件。