Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

“NoSuchMethodErrors” due to multiple versions of org.apache.maven:maven-artifact:jar #4533

Closed
Bing-ok opened this issue Jul 22, 2020 · 5 comments
Milestone

Comments

@Bing-ok
Copy link

Bing-ok commented Jul 22, 2020

Issue description

Hi, there are multiple versions of org.apache.maven:maven-artifact in jersey-2.31\tools\jersey-doc-modulelist-maven-plugin. As shown in the following dependency tree, according to Maven's “nearest wins” strategy, only org.apache.maven:maven-artifact:3.1.1 can be loaded, org.apache.maven:maven-artifact:2.2.0 will be shadowed.

However, one method defined in shadowed version org.apache.maven:maven-artifact:2.2.0 is referenced by client project via org.apache.maven.shared:maven-dependency-tree:2.0, but missing in the actually loaded version org.apache.maven:maven-artifact:3.1.1.

For instance, the following missing method(defined in org.apache.maven:maven-artifact:2.2.0) is actually referenced by jersey-2.31\tools\jersey-doc-modulelist-maven-plugin, which will introduce a runtime error(i.e., "NoSuchMethodErrors") into jersey-2.31\tools\jersey-doc-modulelist-maven-plugin.

Missing method: org.apache.maven.artifact.versioning.ManagedVersionMap: void init (java.util.Map) is invoked by jersey-2.31\tools\jersey-doc-modulelist-maven-plugin via the following path:


paths------
<org.glassfish.jersey.tools.plugins.PredefinedCategories: org.glassfish.jersey.tools.plugins.PredefinedCategories[] values()> jersey-2.31\tools\jersey-doc-modulelist-maven-plugin\target\classes
<org.apache.maven.project.MavenProject: java.lang.Object clone()> Repositories\org\apache\maven\maven-project\2.2.0\maven-project-2.2.0.jar
<org.apache.maven.project.MavenProject: void deepCopy(org.apache.maven.project.MavenProject)> Repositories\org\apache\maven\maven-project\2.2.0\maven-project-2.2.0.jar
<org.apache.maven.artifact.versioning.ManagedVersionMap: void (java.util.Map)>

Suggested fixing solutions

  1. Upgrade dependency org.apache.maven.shared:maven-dependency-tree from 2.0 to 2.2. Because the newer version org.apache.maven.shared:maven-dependency-tree:2.2 does not invoke the above missing method, such upgrading can solve the problem.
  2. Change dependency org.apache.maven:maven-artifact from 3.1.1 to 2.2.0, so that the missing methods will be loaded.

Thank you very much for your attention.
Best regards,

Dependency tree----


[INFO] org.glassfish.jersey.tools.plugins:jersey-doc-modulelist-maven-plugin:maven-plugin:1.0.1
[INFO] +- org.apache.maven:maven-plugin-api:jar:3.1.1:compile
[INFO] |  +- org.apache.maven:maven-model:jar:3.1.1:compile
[INFO] |  |  \- (org.codehaus.plexus:plexus-utils:jar:3.0.15:compile - omitted for duplicate)
[INFO] |  +- (org.apache.maven:maven-artifact:jar:3.1.1:compile - omitted for duplicate)
[INFO] |  \- org.eclipse.sisu:org.eclipse.sisu.plexus:jar:0.0.0.M5:compile
[INFO] |     +- javax.enterprise:cdi-api:jar:1.0:compile
[INFO] |     |  +- javax.annotation:jsr250-api:jar:1.0:compile
[INFO] |     |  \- javax.inject:javax.inject:jar:1:compile
[INFO] |     +- com.google.guava:guava:jar:10.0.1:compile
[INFO] |     |  \- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] |     +- org.sonatype.sisu:sisu-guice:jar:no_aop:3.1.0:compile
[INFO] |     |  +- (javax.inject:javax.inject:jar:1:compile - omitted for duplicate)
[INFO] |     |  \- aopalliance:aopalliance:jar:1.0:compile
[INFO] |     +- org.eclipse.sisu:org.eclipse.sisu.inject:jar:0.0.0.M5:compile
[INFO] |     +- (org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:compile - omitted for duplicate)
[INFO] |     +- (org.codehaus.plexus:plexus-classworlds:jar:2.4:compile - omitted for conflict with 2.5.1)
[INFO] |     \- (org.codehaus.plexus:plexus-utils:jar:2.1:compile - omitted for conflict with 3.0.15)
[INFO] +- org.apache.maven:maven-core:jar:3.1.1:compile
[INFO] |  +- (org.apache.maven:maven-model:jar:3.1.1:compile - omitted for duplicate)
[INFO] |  +- org.apache.maven:maven-settings:jar:3.1.1:compile
[INFO] |  |  \- (org.codehaus.plexus:plexus-utils:jar:3.0.15:compile - omitted for duplicate)
[INFO] |  +- org.apache.maven:maven-settings-builder:jar:3.1.1:compile
[INFO] |  |  +- (org.codehaus.plexus:plexus-utils:jar:3.0.15:compile - omitted for duplicate)
[INFO] |  |  +- (org.codehaus.plexus:plexus-interpolation:jar:1.19:compile - omitted for duplicate)
[INFO] |  |  +- (org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:compile - omitted for duplicate)
[INFO] |  |  +- (org.apache.maven:maven-settings:jar:3.1.1:compile - omitted for duplicate)
[INFO] |  |  \- (org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:compile - omitted for duplicate)
[INFO] |  +- org.apache.maven:maven-repository-metadata:jar:3.1.1:compile
[INFO] |  |  \- (org.codehaus.plexus:plexus-utils:jar:3.0.15:compile - omitted for duplicate)
[INFO] |  +- (org.apache.maven:maven-artifact:jar:3.1.1:compile - omitted for duplicate)
[INFO] |  +- (org.apache.maven:maven-plugin-api:jar:3.1.1:compile - omitted for duplicate)
[INFO] |  +- org.apache.maven:maven-model-builder:jar:3.1.1:compile
[INFO] |  |  +- (org.codehaus.plexus:plexus-utils:jar:3.0.15:compile - omitted for duplicate)
[INFO] |  |  +- (org.codehaus.plexus:plexus-interpolation:jar:1.19:compile - omitted for duplicate)
[INFO] |  |  +- (org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:compile - omitted for duplicate)
[INFO] |  |  \- (org.apache.maven:maven-model:jar:3.1.1:compile - omitted for duplicate)
[INFO] |  +- org.apache.maven:maven-aether-provider:jar:3.1.1:compile
[INFO] |  |  +- (org.apache.maven:maven-model:jar:3.1.1:compile - omitted for duplicate)
[INFO] |  |  +- (org.apache.maven:maven-model-builder:jar:3.1.1:compile - omitted for duplicate)
[INFO] |  |  +- (org.apache.maven:maven-repository-metadata:jar:3.1.1:compile - omitted for duplicate)
[INFO] |  |  +- (org.eclipse.aether:aether-api:jar:0.9.0.M2:compile - omitted for duplicate)
[INFO] |  |  +- org.eclipse.aether:aether-spi:jar:0.9.0.M2:compile
[INFO] |  |  |  \- (org.eclipse.aether:aether-api:jar:0.9.0.M2:compile - omitted for duplicate)
[INFO] |  |  +- (org.eclipse.aether:aether-util:jar:0.9.0.M2:compile - omitted for duplicate)
[INFO] |  |  +- (org.eclipse.aether:aether-impl:jar:0.9.0.M2:compile - omitted for duplicate)
[INFO] |  |  +- (org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:compile - omitted for duplicate)
[INFO] |  |  \- (org.codehaus.plexus:plexus-utils:jar:3.0.15:compile - omitted for duplicate)
[INFO] |  +- org.eclipse.aether:aether-impl:jar:0.9.0.M2:compile
[INFO] |  |  +- (org.eclipse.aether:aether-api:jar:0.9.0.M2:compile - omitted for duplicate)
[INFO] |  |  +- (org.eclipse.aether:aether-spi:jar:0.9.0.M2:compile - omitted for duplicate)
[INFO] |  |  \- (org.eclipse.aether:aether-util:jar:0.9.0.M2:compile - omitted for duplicate)
[INFO] |  +- org.eclipse.aether:aether-api:jar:0.9.0.M2:compile
[INFO] |  +- org.eclipse.aether:aether-util:jar:0.9.0.M2:compile
[INFO] |  |  \- (org.eclipse.aether:aether-api:jar:0.9.0.M2:compile - omitted for duplicate)
[INFO] |  +- (org.eclipse.sisu:org.eclipse.sisu.plexus:jar:0.0.0.M5:compile - omitted for duplicate)
[INFO] |  +- org.codehaus.plexus:plexus-interpolation:jar:1.19:compile
[INFO] |  +- org.codehaus.plexus:plexus-utils:jar:3.0.15:compile
[INFO] |  +- org.codehaus.plexus:plexus-classworlds:jar:2.5.1:compile
[INFO] |  +- org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:compile
[INFO] |  \- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:compile
[INFO] |     +- (org.codehaus.plexus:plexus-utils:jar:1.5.5:compile - omitted for conflict with 3.0.15)
[INFO] |     \- org.sonatype.plexus:plexus-cipher:jar:1.4:compile
[INFO] +- org.apache.maven:maven-artifact:jar:3.1.1:compile
[INFO] |  \- (org.codehaus.plexus:plexus-utils:jar:3.0.15:compile - omitted for duplicate)
[INFO] \- org.apache.maven.shared:maven-dependency-tree:jar:2.0:compile
[INFO]    +- org.apache.maven:maven-project:jar:2.2.0:compile
[INFO]    |  +- (org.apache.maven:maven-settings:jar:2.2.0:compile - omitted for conflict with 3.1.1)
[INFO]    |  +- org.apache.maven:maven-profile:jar:2.2.0:compile
[INFO]    |  |  +- (org.apache.maven:maven-model:jar:2.2.0:compile - omitted for conflict with 3.1.1)
[INFO]    |  |  +- (org.codehaus.plexus:plexus-utils:jar:1.5.15:compile - omitted for conflict with 3.0.15)
[INFO]    |  |  +- (org.codehaus.plexus:plexus-interpolation:jar:1.11:compile - omitted for conflict with 1.19)
[INFO]    |  |  \- (org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile - omitted for duplicate)
[INFO]    |  +- (org.apache.maven:maven-model:jar:2.2.0:compile - omitted for conflict with 3.1.1)
[INFO]    |  +- org.apache.maven:maven-artifact-manager:jar:2.2.0:compile
[INFO]    |  |  +- (org.apache.maven:maven-repository-metadata:jar:2.2.0:compile - omitted for conflict with 3.1.1)
[INFO]    |  |  +- (org.codehaus.plexus:plexus-utils:jar:1.5.15:compile - omitted for conflict with 3.0.15)
[INFO]    |  |  +- (org.apache.maven:maven-artifact:jar:2.2.0:compile - omitted for conflict with 3.1.1)
[INFO]    |  |  +- (org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile - omitted for duplicate)
[INFO]    |  |  +- org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-6:compile
[INFO]    |  |  |  \- (org.codehaus.plexus:plexus-utils:jar:1.4.2:compile - omitted for conflict with 3.0.15)
[INFO]    |  |  \- backport-util-concurrent:backport-util-concurrent:jar:3.1:compile
[INFO]    |  +- org.apache.maven:maven-plugin-registry:jar:2.2.0:compile
[INFO]    |  |  +- (org.codehaus.plexus:plexus-utils:jar:1.5.15:compile - omitted for conflict with 3.0.15)
[INFO]    |  |  \- (org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile - omitted for duplicate)
[INFO]    |  +- (org.codehaus.plexus:plexus-interpolation:jar:1.11:compile - omitted for conflict with 1.19)
[INFO]    |  +- (org.codehaus.plexus:plexus-utils:jar:1.5.15:compile - omitted for conflict with 3.0.15)
[INFO]    |  +- (org.apache.maven:maven-artifact:jar:2.2.0:compile - omitted for conflict with 3.1.1)
[INFO]    |  \- org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile
[INFO]    |     +- junit:junit:jar:3.8.1:compile
[INFO]    |     +- (org.codehaus.plexus:plexus-utils:jar:1.0.4:compile - omitted for conflict with 3.0.15)
[INFO]    |     \- classworlds:classworlds:jar:1.1-alpha-2:compile
[INFO]    \- (org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:compile - omitted for duplicate)
@Bing-ok
Copy link
Author

Bing-ok commented Sep 15, 2020

@senivam Could you please help me review this issue? Thank you very much.

@senivam
Copy link
Contributor

senivam commented Sep 15, 2020

Hi @Bing-ok, preferred solution is to upgrade dependency version.

However it's possible to upgrade just to the newest versions of all dependencies - 3.6.3 and 3.0.1 respectively. The jersey-doc-modulelist-maven-plugin will work as expected and its version will be 1.0.2.

However I'm not sure how do you use it, be case at least my experiments with dependencies and mvn dependency:tree show somehow different output and plugin works in any version without described error.

@Bing-ok
Copy link
Author

Bing-ok commented Sep 15, 2020

You can use command mvn dependency:tree -Dverbose to print the full dependency tree as shown above.

@senivam
Copy link
Contributor

senivam commented Sep 15, 2020

yeah, but the main point was that I can not reproduce described error.

and if you do not have objections against raising versions to the latest (not just to 2.2 of the maven-dependency-tree)

@senivam
Copy link
Contributor

senivam commented Sep 17, 2020

PR #4567 was merged, so issue can be closed as fixed.

@senivam senivam closed this as completed Sep 17, 2020
@senivam senivam added this to the 2.32 milestone Sep 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants