使用 JAX-WS 时,我收到多个 SLF4J 绑定警告、启动处理程序错误和 NoSuchMethodError

发布于 2024-12-22 17:10:33 字数 2869 浏览 4 评论 0原文

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

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

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

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

我尝试一一删除类路径中存在的以下 jar 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 时得到相同(如上所述)的输出。

I am getting multiple SLF4J bindings warnings and Error starting handlers and NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V

Everything was fine ,once I started using JAX-WS, all this business appeared.

One of my colleague got same error but once he removed the jar(jcl-over-slf4j-1.5.8)it is fine for him now,

But I tried same not working for me.

I tried to remove the following jars one by one present in my classpath 1.slf4j-api-1.6.1.jar 2. slf4j-log4j12-1.6.1.jar and 3.slf4j-simple-1.5.8.jar but no effect.

When I tried maven clean before running Jetty it was showing build error and unable to to delete (xmlsec-1.4.4.jar),I manually removed this jar still not building anything to my .M2 repository.

Here is the console output:

        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)

Please give me some input I tried lot of permutations but getting the same (as above) output when Running Jetty.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦里梦着梦中梦 2024-12-29 17:10:34

Maven 自动包含不同版本的 slf4j-api 以及 slf4j-log4j 或 slf4j-logging。您可以通过键入以下内容找出包含它们的原因:

mvn dependency:tree -Dincludes=org.slf4j

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

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

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

Maven is including automatically different versions of slf4j-api and either slf4j-log4j or slf4j-logging. You can find out why they are being included by typing:

mvn dependency:tree -Dincludes=org.slf4j

Since you're using Jetty, it may also be that Jetty is including the container's classpath with your app. Try adding the following line (if it's Jetty 6 or older) to your webapp's context file:

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

It should set the container jars and resources to be lower priority than your webapp ones.

守护在此方 2024-12-29 17:10:34

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

You still have slf4j-simple-1.5.8.jar in your classpath (at src/main/webapp/WEB-INF/lib/slf4j-simple-1.5.8.jar) according to the error message. What tool (Ant, Maven) are you using for your build process?

っ〆星空下的拥抱 2024-12-29 17:10:34

这似乎是由加载的 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.

如果多次找到,那么您可以通过在每个依赖项中写入此内容来排除它

    <exclusions>
      <exclusion>
        <artifactId>[artifactId]</artifactId>
        <groupId>[groupId]</groupId>
      </exclusion>
    </exclusions>

It seems like caused by incompatible versions of slf4j being loaded.Try this

-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.

If you find multiple times, then you can exclude it by writing this in each dependency

    <exclusions>
      <exclusion>
        <artifactId>[artifactId]</artifactId>
        <groupId>[groupId]</groupId>
      </exclusion>
    </exclusions>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文