zeroturnaround / zt-zip

ZeroTurnaround ZIP Library
http://www.zeroturnaround.com/
Apache License 2.0
1.38k stars 251 forks source link

java.lang.LinkageError: loader constraint violation: when resolving method #142

Closed danechitoaie closed 3 years ago

danechitoaie commented 3 years ago

Trying to use zt-zip in a Jenkins and I get the following error

java.lang.LinkageError: loader constraint violation: when resolving method "org.slf4j.impl.StaticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory;" the class loader (instance of hudson/PluginFirstClassLoader) of the current class, org/slf4j/LoggerFactory, and the class loader (instance of org/eclipse/jetty/webapp/WebAppClassLoader) for the method's defining class, org/slf4j/impl/StaticLoggerBinder, have different Class objects for the type org/slf4j/ILoggerFactory used in the signature
    at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:423)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
    at org.zeroturnaround.zip.ZipUtil.<clinit>(ZipUtil.java:70)
    at org.jenkinsci.plugins.osfbuildersuiteforsfcc.deploy.DeployBuilder$DeployCallable.invoke(DeployBuilder.java:707)
    at org.jenkinsci.plugins.osfbuildersuiteforsfcc.deploy.DeployBuilder$DeployCallable.invoke(DeployBuilder.java:442)
    at hudson.FilePath.act(FilePath.java:1164)
    at hudson.FilePath.act(FilePath.java:1147)
    at org.jenkinsci.plugins.osfbuildersuiteforsfcc.deploy.DeployBuilder.perform(DeployBuilder.java:267)
    at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123)
    at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:99)
    at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:69)
    at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

Any idea what I can do to fix this?

nemecec commented 3 years ago

Judging by the error message, you have SLF4J JAR file in Jenkins plugin and in Jetty webapp classloader. Nothing to do with zt-zip, you have to fix your environment.

danechitoaie commented 3 years ago

I had <pluginFirstClassLoader>true</pluginFirstClassLoader> in my POM and I guess this was causing the conflict. I removed that and then I was able to compile the plugin. It's strange that I only got this issue with zt-zip and other dependencies don't. Maybe only zt-zip uses slf4j and others don't? I really hope I won't have to go back to <pluginFirstClassLoader>true</pluginFirstClassLoader> as I'll have no idea how to solve this conflict then.