slf4j warning about the same binding being duplicate

微笑、不失礼 提交于 2019-12-12 12:02:55

问题


SLF4J complains about multiple bindings, but those look exactly the same:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [zip:C:/bea_domains/my_service_domain/servers/AdminServer/tmp/_WL_user/my-shared-app-lib/obaz3z/APP-INF/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [zip:C:/bea_domains/my_service_domain/servers/AdminServer/tmp/_WL_user/my-shared-app-lib/obaz3z/APP-INF/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

Is there any way to get rid of this warning? What could be the reason of it?


回答1:


There is currently discussion going on bug 138 which seem to me identical to the issue you reported. According to the discussion, "the problem was, actually, in multiple classpaths in manifests - if there was more than EJB jar with binding listed WLS was providing a full list of those. Even if the class was the same. This goes with the ClassLoader behavior in WLS.". If you want to really remove this warning (though not fatal), there is a attachment in the bug, you could probably patch slf4j with it.




回答2:


Bug 138 has been fixed in slf4j 1.6.2 now :-). http://www.slf4j.org/news.html




回答3:


Apart from the problem with multiple classpaths described in Jasonw's answer, this problem can also be caused by the mocking framework PowerMock.

PowerMock uses its own class loader (MockClassLoader), which uses its own mechanism for delegating to the parent class loader. This can also cause ClassLoader.getResources() to return the same resource twice, which triggers the warning.

This seems to be caused by the changes described in PowerMock issue 380.

The fix for but #138 in SLF4J (linked above) solves this problem, too, so with SLF4J 1.6.2+ it should no longer occur.



来源:https://stackoverflow.com/questions/6418147/slf4j-warning-about-the-same-binding-being-duplicate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!