maven-mvnd icon indicating copy to clipboard operation
maven-mvnd copied to clipboard

Cannot use Maven plugins that use slf4j-log4j12

Open rasmusfaber opened this issue 3 years ago • 6 comments

If you try to use mvnd with a maven plugin that uses slf4j-log4j12, the build fails with

java.lang.IllegalStateException: Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOverflowError. See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
	at org.slf4j.impl.Log4jLoggerFactory.<clinit>(Log4jLoggerFactory.java:54)

due to the presence of log4j-over-slf4j in the daemon classloader.

If I build a version of the daemon without the log4j-over-slf4j-dependency, everything seems to work fine, so that might be an easy fix, but it might be there for a reason?

rasmusfaber avatar Dec 11 '21 18:12 rasmusfaber

Could you please name and example of a plugin using slf4j-log4j12?

ppalaga avatar Dec 14 '21 07:12 ppalaga

I wasn't able to find any public maven plugins that uses slf4j-log4j12 (ran through the first 20 pages of https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12/usages without spotting anything that looked like a maven plugin), but we have an internal project that uses three of them.

I can probably get the dependency removed from them, so the issue is not critical (well, even the use of mvndaemon is just a quality of life improvement), but I wanted to at least log the issue if anyone else ran into the same problem.

rasmusfaber avatar Dec 14 '21 12:12 rasmusfaber

Could be related to https://github.com/mvndaemon/mvnd/issues/183

gnodet avatar Dec 14 '21 12:12 gnodet

Yes, certainly your suggestion about isolating the classloaders (https://github.com/mvndaemon/mvnd/issues/183#issuecomment-775922833 ) would fix this issue as well.

rasmusfaber avatar Dec 14 '21 13:12 rasmusfaber

@rasmusfaber does that actually work well with stock maven ?

gnodet avatar Dec 15 '21 06:12 gnodet

Yes, the build works perfectly with stock maven.

rasmusfaber avatar Dec 15 '21 13:12 rasmusfaber