jvelo / mayocat-shop

[RETIRED] Open source e-commerce and marketplaces made simple on the JVM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

java.lang.NoSuchMethodError caused by dependency conflicts of multiple versions of logback

LeoAugust19 opened this issue · comments

Hi, there are multiple versions of ch.qos.logback:logback-classic:jar in org.mayocat.platform:mayocat-platform-model:jar:0.30.1. Due to Maven version management, only ch.qos.logback:logback-core:jar:1.0.10 can be loaded and the other versions will be shadowed during the packaging process.

However, method <ch.qos.logback.core.util.Loader: java.util.Set getResourceOccurenceCount(java.lang.String,java.lang.ClassLoader)> only defined in the shadowed version ch.qos.logback:logback-core:jar:1.0.6. As a result, an exception will be thrown when your project referencing the missing method.

Dependency tree
org.mayocat.platform:mayocat-platform-model:jar:0.30.1
+- org.xwiki.commons:xwiki-commons-observation-api:jar:4.5.2:compile
+- com.yammer.dropwizard:dropwizard-core:jar:0.6.2:compile
| +- com.yammer.metrics:metrics-logback:jar:2.2.0:compile
| +- ch.qos.logback:logback-core:jar:1.0.10:compile
| +- (ch.qos.logback:logback-classic:jar:1.0.10:compile - omitted for conflict with 1.0.6)
| - com.fasterxml.jackson.datatype:jackson-datatype-joda:jar:2.1.2:compile
| +- (com.fasterxml.jackson.core:jackson-core:jar:2.1.2:compile - omitted for conflict with 2.1.4)
| +- (com.fasterxml.jackson.core:jackson-databind:jar:2.1.2:compile - omitted for conflict with 2.1.4)
| - (joda-time:joda-time:jar:2.1:compile - omitted for conflict with 2.2)
+- ch.qos.logback:logback-classic:jar:1.0.6:compile
| +- (ch.qos.logback:logback-core:jar:1.0.6:compile - omitted for conflict with 1.0.10)
| - (org.slf4j:slf4j-api:jar:1.6.5:compile - omitted for conflict with 1.7.4)
- org.jmock:jmock:jar:2.6.0-RC2:compile
+- org.hamcrest:hamcrest-core:jar:1.3.RC2:compile
- org.hamcrest:hamcrest-library:jar:1.3.RC2:compile
- (org.hamcrest:hamcrest-core:jar:1.3.RC2:compile - omitted for duplicate)

Solution
Upgrade ch.qos.logback:logback-classic to version 1.0.10.

Do you need stack trace or test case to investigate this issue? I can try to provide you more information.

Thanks a lot.

Regards,
Leo

@jvelo

Stack trace

java.lang.NoSuchMethodError: ch.qos.logback.core.util.Loader.getResourceOccurenceCount(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/util/Set;
at ch.qos.logback.classic.util.ContextInitializer.multiplicityWarning(ContextInitializer.java:158)
at ch.qos.logback.classic.util.ContextInitializer.statusOnResourceSearch(ContextInitializer.java:181)
at ch.qos.logback.classic.util.ContextInitializer.getResource(ContextInitializer.java:139)
at ch.qos.logback.classic.util.ContextInitializer.findURLOfDefaultConfigurationFile(ContextInitializer.java:133)
at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:146)
at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:54)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)
at org.mayocat.model.AttachmentData.(AttachmentData.java:27)

Using the following test case can reproduce the issue.
Test1.txt

@jvelo Hi, may I pull a request to fix this issue?

@LeoAugust19 yes, of course. I'm not active on the project any longer but will merge good pull requests.
FYI I'm open to grant commit rights if there are parties interested in moving the project forward.

@jvelo Thanks a lot for your feedback. I'd like to join your organization to move the nice project forward.
I will pull a request later.