dromara / myth

Reliable messages resolve distributed transactions
https://dromara.org
Apache License 2.0
1.49k stars 603 forks source link

“NoSuchMethodErrors” due to multiple versions of org.slf4j:slf4j-api:jar #68

Closed Bing-ok closed 4 years ago

Bing-ok commented 4 years ago

Hi, there are multiple versions of org.slf4j:slf4j-api in myth-master\myth-rpc\myth-motan. As shown in the following dependency tree, according to Maven's “nearest wins” strategy, only org.slf4j:slf4j-api:1.7.25 can be loaded, and org.slf4j:slf4j-api:1.5.8 will be shadowed.

As org.slf4j:slf4j-api:1.5.8 has not been loaded during the building process, several methods are missing. However, the missing methods: 1. org.slf4j.helpers.MessageFormatter: java.lang.String format(java.lang.String,java.lang.Object)

Check for details of invocation
paths------
<org.dromara.myth.motan.interceptor.MotanMythTransactionInterceptor: java.lang.Object interceptor(org.aspectj.lang.ProceedingJoinPoint)> myth-master\myth-rpc\myth-motan\target\classes
<org.dromara.myth.core.service.impl.MythTransactionAspectServiceImpl: java.lang.Object invoke(org.dromara.myth.common.bean.context.MythTransactionContext,org.aspectj.lang.ProceedingJoinPoint)> Repositories\org\dromara\myth-core\2.0.2-RELEASE\myth-core-2.0.2-RELEASE.jar
<org.dromara.myth.core.service.handler.ActorMythTransactionHandler: java.lang.Object handler(org.aspectj.lang.ProceedingJoinPoint,org.dromara.myth.common.bean.context.MythTransactionContext)> Repositories\org\dromara\myth-core\2.0.2-RELEASE\myth-core-2.0.2-RELEASE.jar
<org.dromara.myth.common.utils.LogUtil: void error(org.slf4j.Logger,java.lang.String,java.util.function.Supplier)> Repositories\org\dromara\myth-common\2.0.2-RELEASE\myth-common-2.0.2-RELEASE.jar
<org.slf4j.impl.Log4jLoggerAdapter: void error(java.lang.String,java.lang.Object)> Repositories\org\slf4j\slf4j-log4j12\1.7.25\slf4j-log4j12-1.7.25.jar
<org.slf4j.helpers.MessageFormatter: java.lang.String format(java.lang.String,java.lang.Object)>

The above missing methods are actually referenced by myth-master\myth-rpc\myth-motan, which will cause “NoSuchMethodErrors” at runtime.

Suggested fixing solutions:

  1. Upgrading dependency com.weibo:motan-core, com.weibo:motan-springsupport and com.weibo:motan-transport-netty from 1.0.0 to 1.1.2 can solve this dependency conflict.
  2. Change dependency org.slf4j:slf4j-api from 1.7.25 to 1.5.8.
  3. Use configuration attribute <dependencyManagement> to unify the version of library org.slf4j:slf4j-api to be 1.5.8 in myth-master\myth-rpc\myth-motan's pom file.

Please let me know which solution do you prefer? I can submit a PR to fix it.

Thank you very much for your attention. Best regards,

Dependency tree----

click for details
[INFO] org.dromara:myth-motan:jar:2.0.2-RELEASE
[INFO] +- org.dromara:myth-core:jar:2.0.2-RELEASE:compile
[INFO] | +- org.dromara:myth-common:jar:2.0.2-RELEASE:compile
[INFO] | | +- (org.dromara:myth-annotation:jar:2.0.2-RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.apache.commons:commons-lang3:jar:3.3.2:compile - omitted for duplicate)
[INFO] | | +- commons-beanutils:commons-beanutils:jar:1.9.4:compile
[INFO] | | | \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] | | +- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] | | +- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] | | +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] | | | +- (ch.qos.logback:logback-core:jar:1.2.3:compile - omitted for duplicate)
[INFO] | | | \- (org.slf4j:slf4j-api:jar:1.7.25:compile - omitted for duplicate)
[INFO] | | +- com.google.code.gson:gson:jar:2.6.2:compile
[INFO] | | +- com.squareup.okhttp3:okhttp:jar:3.7.0:compile
[INFO] | | | \- com.squareup.okio:okio:jar:1.12.0:compile
[INFO] | | +- com.google.guava:guava:jar:21.0:compile
[INFO] | | +- redis.clients:jedis:jar:2.9.0:compile
[INFO] | | | \- org.apache.commons:commons-pool2:jar:2.6.0:compile (version managed from 2.4.2)
[INFO] | | +- org.projectlombok:lombok:jar:1.16.20:compile
[INFO] | | +- com.esotericsoftware:kryo-shaded:jar:4.0.0:compile
[INFO] | | | +- com.esotericsoftware:minlog:jar:1.3.0:compile
[INFO] | | | \- org.objenesis:objenesis:jar:2.2:compile
[INFO] | | +- com.dyuproject.protostuff:protostuff-core:jar:1.0.8:compile
[INFO] | | | \- com.dyuproject.protostuff:protostuff-api:jar:1.0.8:compile
[INFO] | | +- com.dyuproject.protostuff:protostuff-runtime:jar:1.0.8:compile
[INFO] | | | +- (com.dyuproject.protostuff:protostuff-api:jar:1.0.8:compile - omitted for duplicate)
[INFO] | | | \- com.dyuproject.protostuff:protostuff-collectionschema:jar:1.0.8:compile
[INFO] | | | \- (com.dyuproject.protostuff:protostuff-api:jar:1.0.8:compile - omitted for duplicate)
[INFO] | | +- com.caucho:hessian:jar:4.0.38:compile
[INFO] | | \- org.mongodb:mongo-java-driver:jar:3.5.0:compile
[INFO] | +- org.dromara:myth-annotation:jar:2.0.2-RELEASE:compile
[INFO] | +- org.aspectj:aspectjweaver:jar:1.8.9:compile
[INFO] | +- com.lmax:disruptor:jar:3.4.0:compile
[INFO] | \- org.apache.zookeeper:zookeeper:jar:3.4.9:compile
[INFO] | +- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.6.1; omitted for duplicate)
[INFO] | +- log4j:log4j:jar:1.2.14:compile
[INFO] | +- jline:jline:jar:0.9.94:compile
[INFO] | \- io.netty:netty:jar:3.10.5.Final:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.3.2:compile
[INFO] +- org.springframework:spring-context:jar:5.1.3.RELEASE:provided
[INFO] | +- org.springframework:spring-aop:jar:5.1.3.RELEASE:provided
[INFO] | | +- (org.springframework:spring-beans:jar:5.1.3.RELEASE:provided - omitted for duplicate)
[INFO] | | \- (org.springframework:spring-core:jar:5.1.3.RELEASE:provided - omitted for duplicate)
[INFO] | +- org.springframework:spring-beans:jar:5.1.3.RELEASE:provided
[INFO] | | \- (org.springframework:spring-core:jar:5.1.3.RELEASE:provided - omitted for duplicate)
[INFO] | +- org.springframework:spring-core:jar:5.1.3.RELEASE:provided
[INFO] | | \- org.springframework:spring-jcl:jar:5.1.3.RELEASE:provided
[INFO] | \- org.springframework:spring-expression:jar:5.1.3.RELEASE:provided
[INFO] | \- (org.springframework:spring-core:jar:5.1.3.RELEASE:provided - omitted for duplicate)
[INFO] +- com.weibo:motan-core:jar:1.0.0:provided
[INFO] | +- commons-pool:commons-pool:jar:1.6:provided
[INFO] | +- (com.caucho:hessian:jar:4.0.38:compile - scope updated from provided; omitted for duplicate)
[INFO] | +- com.alibaba:fastjson:jar:1.1.30:provided
[INFO] | +- com.codahale.metrics:metrics-core:jar:3.0.1:provided
[INFO] | | \- (org.slf4j:slf4j-api:jar:1.7.25:provided - version managed from 1.7.5; omitted for duplicate)
[INFO] | +- (com.google.guava:guava:jar:21.0:compile - version managed from 18.0; scope updated from provided; omitted for duplicate)
[INFO] | +- com.squareup:javapoet:jar:1.8.0:provided
[INFO] | +- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.5.8; scope updated from provided; omitted for duplicate)
[INFO] | +- org.slf4j:slf4j-log4j12:jar:1.7.25:provided (version managed from 1.5.8)
[INFO] | | +- (org.slf4j:slf4j-api:jar:1.7.25:provided - version managed from 1.5.8; omitted for duplicate)
[INFO] | | \- (log4j:log4j:jar:1.2.17:provided - omitted for conflict with 1.2.14)
[INFO] | +- (log4j:log4j:jar:1.2.14:compile - scope updated from provided; omitted for duplicate)
[INFO] | +- (org.apache.commons:commons-lang3:jar:3.3.2:provided - version managed from 3.1; omitted for duplicate)
[INFO] | \- commons-codec:commons-codec:jar:1.11:provided (version managed from 1.4)
[INFO] +- com.weibo:motan-springsupport:jar:1.0.0:provided
[INFO] | +- (com.weibo:motan-core:jar:1.0.0:provided - omitted for duplicate)
[INFO] | +- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.5.8; scope updated from provided; omitted for duplicate)
[INFO] | +- (org.slf4j:slf4j-log4j12:jar:1.7.25:provided - version managed from 1.5.8; omitted for duplicate)
[INFO] | +- (log4j:log4j:jar:1.2.14:compile - scope updated from provided; omitted for duplicate)
[INFO] | +- (org.apache.commons:commons-lang3:jar:3.3.2:provided - version managed from 3.1; omitted for duplicate)
[INFO] | \- (commons-codec:commons-codec:jar:1.11:provided - version managed from 1.4; omitted for duplicate)
[INFO] \- com.weibo:motan-transport-netty:jar:1.0.0:provided
[INFO] +- org.jboss.netty:netty:jar:3.2.5.Final:provided
[INFO] +- (com.weibo:motan-core:jar:1.0.0:provided - omitted for duplicate)
[INFO] +- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.5.8; scope updated from provided; omitted for duplicate)
[INFO] +- (org.slf4j:slf4j-log4j12:jar:1.7.25:provided - version managed from 1.5.8; omitted for duplicate)
[INFO] +- (log4j:log4j:jar:1.2.14:compile - scope updated from provided; omitted for duplicate)
[INFO] +- (org.apache.commons:commons-lang3:jar:3.3.2:provided - version managed from 3.1; omitted for duplicate)
[INFO] \- (commons-codec:commons-codec:jar:1.11:provided - version managed from 1.4; omitted for duplicate)
Bing-ok commented 4 years ago

捕获 About solution No.1

Bing-ok commented 4 years ago

Could you help me review this issue? 👍 Thanks! @yu199195

yu199195 commented 4 years ago

@Bing-ok hi, solution 3 maybe good idea, you can pr fix it

Bing-ok commented 4 years ago

Thanks for your support!