slf4j warning about the same binding being duplica

2019-06-24 04:50发布

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?

3条回答
劫难
2楼-- · 2019-06-24 05:26

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.

查看更多
Juvenile、少年°
3楼-- · 2019-06-24 05:50

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.

查看更多
Explosion°爆炸
4楼-- · 2019-06-24 05:53

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

查看更多
登录 后发表回答