“NoSuchMethodErrors” due to multiple versions of org.apache.commons:commons-lang3:jar
Bing-ok opened this issue · 2 comments
Issue description
Hi, there are multiple versions of org.apache.commons:commons-lang3 in weixin-java-mp-multi-demo. As shown in the following dependency tree, according to Maven's “nearest wins” strategy, only org.apache.commons:commons-lang3:3.4 can be loaded, and org.apache.commons:commons-lang3:3.10 will be shadowed.
However, several methods defined in shadowed version org.apache.commons:commons-lang3:3.10 are referenced by client project via com.github.binarywang:weixin-java-mp:3.9.0, but missing in the actually loaded version org.apache.commons:commons-lang3:3.4.
For instance, the following missing methods(defined in org.apache.commons:commons-lang3:3.10) are actually referenced by weixin-java-mp-multi-demo, which will introduce a runtime error(i.e., "NoSuchMethodError") into weixin-java-mp-multi-demo.
1. org.apache.commons.lang3.StringUtils: java.lang.String replaceAll(java.lang.String,java.lang.String,java.lang.String) is invoked by weixin-java-mp-multi-demo via the following path:
paths------
<com.github.binarywang.demo.wx.mp.handler.SubscribeHandler: me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage handle(me.chanjar.weixin.mp.bean.message.WxMpXmlMessage,java.util.Map,me.chanjar.weixin.mp.api.WxMpService,me.chanjar.weixin.common.session.WxSessionManager)> weixin-java-mp-multi-demo\target\classes
<me.chanjar.weixin.mp.api.impl.WxMpUserServiceImpl: me.chanjar.weixin.mp.bean.result.WxMpUser userInfo(java.lang.String,java.lang.String)> Repositories\com\github\binarywang\weixin-java-mp\3.9.0\weixin-java-mp-3.9.0.jar
<me.chanjar.weixin.mp.api.impl.BaseWxMpServiceImpl: java.lang.String get(me.chanjar.weixin.mp.enums.WxMpApiUrl,java.lang.String)> Repositories\com\github\binarywang\weixin-java-mp\3.9.0\weixin-java-mp-3.9.0.jar
<me.chanjar.weixin.mp.api.impl.BaseWxMpServiceImpl: java.lang.String get(java.lang.String,java.lang.String)> Repositories\com\github\binarywang\weixin-java-mp\3.9.0\weixin-java-mp-3.9.0.jar
<me.chanjar.weixin.mp.api.impl.BaseWxMpServiceImpl: java.lang.Object execute(me.chanjar.weixin.common.util.http.RequestExecutor,java.lang.String,java.lang.Object)> Repositories\com\github\binarywang\weixin-java-mp\3.9.0\weixin-java-mp-3.9.0.jar
<me.chanjar.weixin.mp.api.impl.BaseWxMpServiceImpl: java.lang.Object executeInternal(me.chanjar.weixin.common.util.http.RequestExecutor,java.lang.String,java.lang.Object)> Repositories\com\github\binarywang\weixin-java-mp\3.9.0\weixin-java-mp-3.9.0.jar
<me.chanjar.weixin.common.util.DataUtils: java.lang.Object handleDataWithSecret(java.lang.Object)> Repositories\com\github\binarywang\weixin-java-common\3.9.0\weixin-java-common-3.9.0.jar
<org.apache.commons.lang3.StringUtils: java.lang.String replaceAll(java.lang.String,java.lang.String,java.lang.String)>
Suggested fixing solutions
Upgrade direct dependency org.apache.commons:commons-lang3 from 3.4 to 3.10.
Thank you very much for your attention.
Best regards,
Dependency tree----
[INFO] com.github.binarywang:weixin-java-mp-multi-demo:war:0.0.1-SNAPSHOT
[INFO] +- com.github.binarywang:weixin-java-mp:jar:3.9.0:compile
[INFO] | \- com.github.binarywang:weixin-java-common:jar:3.9.0:compile
[INFO] | +- (org.slf4j:slf4j-api:jar:1.7.24:compile - omitted for conflict with 1.7.2)
[INFO] | +- com.thoughtworks.xstream:xstream:jar:1.4.11.1:compile
[INFO] | | +- xmlpull:xmlpull:jar:1.1.3.1:compile
[INFO] | | \- xpp3:xpp3_min:jar:1.1.4c:compile
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.5:compile
[INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.4.1:compile
[INFO] | | \- (commons-codec:commons-codec:jar:1.9:compile - omitted for conflict with 1.10)
[INFO] | +- org.apache.httpcomponents:httpmime:jar:4.5:compile
[INFO] | | \- (org.apache.httpcomponents:httpclient:jar:4.5:compile - omitted for duplicate)
[INFO] | +- org.slf4j:jcl-over-slf4j:jar:1.7.24:compile
[INFO] | | \- (org.slf4j:slf4j-api:jar:1.7.24:compile - omitted for duplicate)
[INFO] | +- com.google.code.gson:gson:jar:2.8.0:compile
[INFO] | +- commons-codec:commons-codec:jar:1.10:compile
[INFO] | +- commons-io:commons-io:jar:2.5:compile
[INFO] | +- (org.apache.commons:commons-lang3:jar:3.10:compile - omitted for conflict with 3.4)
[INFO] | +- (com.google.guava:guava:jar:29.0-android:compile - omitted for conflict with 24.1.1-jre)
[INFO] | \- org.dom4j:dom4j:jar:2.1.3:compile
[INFO] +- com.alibaba:fastjson:jar:1.2.31:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.4:compile
[INFO] +- com.google.guava:guava:jar:24.1.1-jre:compile
[INFO] | +- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] | +- org.checkerframework:checker-compat-qual:jar:2.0.0:compile
[INFO] | +- com.google.errorprone:error_prone_annotations:jar:2.1.3:compile
[INFO] | +- com.google.j2objc:j2objc-annotations:jar:1.1:compile
[INFO] | \- org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.2:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.2:compile
[INFO] | \- log4j:log4j:jar:1.2.17:compile
[INFO] +- org.springframework:spring-webmvc:jar:4.3.2.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:4.3.2.RELEASE:compile
[INFO] | | +- (org.springframework:spring-beans:jar:4.3.2.RELEASE:compile - omitted for duplicate)
[INFO] | | \- (org.springframework:spring-core:jar:4.3.2.RELEASE:compile - omitted for duplicate)
[INFO] | +- org.springframework:spring-beans:jar:4.3.2.RELEASE:compile
[INFO] | | \- (org.springframework:spring-core:jar:4.3.2.RELEASE:compile - omitted for duplicate)
[INFO] | +- org.springframework:spring-context:jar:4.3.2.RELEASE:compile
[INFO] | | +- (org.springframework:spring-aop:jar:4.3.2.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-beans:jar:4.3.2.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-core:jar:4.3.2.RELEASE:compile - omitted for duplicate)
[INFO] | | \- (org.springframework:spring-expression:jar:4.3.2.RELEASE:compile - omitted for duplicate)
[INFO] | +- org.springframework:spring-core:jar:4.3.2.RELEASE:compile
[INFO] | | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] | +- org.springframework:spring-expression:jar:4.3.2.RELEASE:compile
[INFO] | | \- (org.springframework:spring-core:jar:4.3.2.RELEASE:compile - omitted for duplicate)
[INFO] | \- (org.springframework:spring-web:jar:4.3.2.RELEASE:compile - omitted for duplicate)
[INFO] +- org.springframework:spring-web:jar:4.3.2.RELEASE:compile
[INFO] | +- (org.springframework:spring-aop:jar:4.3.2.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-beans:jar:4.3.2.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-context:jar:4.3.2.RELEASE:compile - omitted for duplicate)
[INFO] | \- (org.springframework:spring-core:jar:4.3.2.RELEASE:compile - omitted for duplicate)
[INFO] +- org.springframework.security:spring-security-core:jar:4.2.17.RELEASE:compile
[INFO] | +- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- (org.springframework:spring-aop:jar:4.3.26.RELEASE:compile - omitted for conflict with 4.3.2.RELEASE)
[INFO] | +- (org.springframework:spring-beans:jar:4.3.26.RELEASE:compile - omitted for conflict with 4.3.2.RELEASE)
[INFO] | +- (org.springframework:spring-context:jar:4.3.26.RELEASE:compile - omitted for conflict with 4.3.2.RELEASE)
[INFO] | +- (org.springframework:spring-core:jar:4.3.26.RELEASE:compile - omitted for conflict with 4.3.2.RELEASE)
[INFO] | \- (org.springframework:spring-expression:jar:4.3.26.RELEASE:compile - omitted for conflict with 4.3.2.RELEASE)
[INFO] +- org.aspectj:aspectjrt:jar:1.8.9:compile
[INFO] +- org.aspectj:aspectjweaver:jar:1.8.9:compile
[INFO] \- com.fasterxml.jackson.core:jackson-databind:jar:2.10.0.pr1:compile
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.10.0.pr1:compile
[INFO] \- com.fasterxml.jackson.core:jackson-core:jar:2.10.0.pr1:compile
@binarywang Could you please help me review this issue? Thank you very much.
去掉多余依赖即可。
另外已不建议使用此demo,这里的实现方式不是很优雅。
建议参考另一个demo,首页里提到的。