繁体   English   中英

使用JAX-WS时出现多个SLF4J绑定警告和错误启动处理程序以及NoSuchMethodError

[英]I am getting multiple SLF4J bindings warnings and Error starting handlers and NoSuchMethodError when using JAX-WS

我收到多个SLF4J绑定警告错误启动处理程序以及NoSuchMethodError:org.slf4j.spi.LocationAwareLogger.log(Lorg / slf4j / Marker; Ljava / lang / String; ILjava / lang / String; Ljava / lang / Throwable;)V

一切都很好,一旦我开始使用JAX-WS,所有这些业务就出现了。

我的一位同事犯了同样的错误,但是一旦他删除了罐子(jcl-over-slf4j-1.5.8),现在对他来说就好了,

但是我尝试了同样对我不起作用的方法。

我试图删除我的类路径1.slf4j-api-1.6.1.jar 2. slf4j-log4j12-1.6.1.jar和3.slf4j-simple-1.5.8.jar中存在的罐子。影响。

当我在运行Jetty之前尝试进行maven clean时,它显示生成错误并且无法删除(xmlsec-1.4.4.jar),我手动删除了这个jar,但仍然没有为.M2存储库构建任何内容。

这是控制台输出:

        2011-12-23 08:44:55.765:INFO::jetty-6.1.26
    SLF4J: Class path contains multiple SLF4J bindings.
    SLF4J: Found binding in [jar:file:/C:/My_workspace/my_portal            /MyPortal/trunk/MyPortalWebApp/src/main/webapp/WEB-INF/lib/slf4j-        log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/My_workspace/MyPortal/trunk/MyPortalWebApp/src/main/webapp/WEB-INF/lib/slf4j-simple-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
2011-12-23 08:44:57.140:INFO:/MyPortalWebApp:Initializing Spring root WebApplicationContext
2011-12-23 08:44:57.140:WARN::failed org.mortbay.jetty.webapp.WebAppContext@c4fe76    {/MyPortalWebApp,C:\My_workspace\MyPortal\trunk\MyPortalWebApp\src\main\webapp}: java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
2011-12-23 08:44:57.140:WARN::Error starting handlers
java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.info(SLF4JLocationAwareLog.java:159)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
at org.springframework.web.context.ContextLoaderListener.contextInitialized        (ContextLoaderListener.java:47)
at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:549)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:224)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at runjettyrun.Bootstrap.main(Bootstrap.java:82)

请给我一些输入,我尝试了很多排列,但是在运行Jetty时得到了相同的输出(如上所述)。

Maven自动包含了不同版本的slf4j-api和slf4j-log4j或slf4j-logging。 您可以通过键入以下内容来找出为什么要包含它们:

mvn dependency:tree -Dincludes=org.slf4j

由于您使用的是Jetty,也可能是Jetty在您的应用程序中包含了容器的类路径。 尝试将以下行(如果是Jetty 6或更早版本)添加到Webapp的上下文文件中:

<Set name="parentLoaderPriority">false</Set>

它应该将容器jar和资源的优先级设置为低于您的Webapp。

似乎是由于加载了不兼容的slf4j版本引起的。

-In eclipse, open the pom.xml file.
-select the Dependency Hierarchy tab at the bottom. 
-In the search filter, type the name "slf4j" and see all the dependencies that depend on slf4j for logging.

如果发现多次,则可以通过在每个依赖项中编写此代码来排除它

&ltexclusions>
      &ltexclusion>
        &ltartifactId>[artifactId]</artifactId>
        &ltgroupId>[groupId]</groupId>
      </exclusion>
    </exclusions>

根据错误消息,您的类路径中仍然有slf4j-simple-1.5.8.jar (位于src/main/webapp/WEB-INF/lib/slf4j-simple-1.5.8.jar )。 您在构建过程中使用什么工具(Ant,Maven)?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM