Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我在使用JAX-WS时收到多个SLF4J绑定警告和启动处理程序时出错以及NoSuchMethodError_Java_Jax Ws_Slf4j - Fatal编程技术网

Java 我在使用JAX-WS时收到多个SLF4J绑定警告和启动处理程序时出错以及NoSuchMethodError

Java 我在使用JAX-WS时收到多个SLF4J绑定警告和启动处理程序时出错以及NoSuchMethodError,java,jax-ws,slf4j,Java,Jax Ws,Slf4j,我收到多个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),他现在就没事了 但我也试过同

我收到多个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中的以下jar。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时得到了相同的(如上)输出。

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

Maven自动包含不同版本的slf4j api和slf4j-log4j或slf4j日志记录。您可以通过键入以下内容来了解它们被包含的原因:

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

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

它应该将容器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. -在eclipse中,打开pom.xml文件。 -选择底部的依赖关系层次选项卡。 -在搜索筛选器中,键入名称“slf4j”,并查看所有依赖slf4j进行日志记录的依赖项。 如果找到多次,则可以通过在每个依赖项中写入此项来排除它

<exclusions> <exclusion> <artifactId>[artifactId]</artifactId> <groupId>[groupId]</groupId> </exclusion> </exclusions> <exclusions> <exclusion> <artifactId>[artifactId]</artifactId> <groupId>[groupId]</groupId> </排除> </除外条款>