Skip to content

java.lang.NoClassDefFoundError caused by dependency conflicts of multiple versions of com.google.guava:guava:jar #1371

@LeoAugust19

Description

@LeoAugust19

Hi, there are multiple versions of com.google.guava:guava:jar in mil.nga.giat:geowave-grpc-protobuf-shaded:jar:0.9.7. Due to Maven version management, only com.google.guava:guava:jar:14.0-rc1 can be loaded and the other versions will be shadowed during the packaging process.

However, class com/google/common/base/MoreObjects only defined in the shadowed version com.google.guava:guava:jar:19.0. As a result, an exception will be thrown when your project referencing the missing class.

Stack trace

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/MoreObjects
at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:284)
at Test1.main(Test1.java:7)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.MoreObjects
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more

Using the following test case you can reproduce this problem.
Test1.txt

Dependency tree

mil.nga.giat:geowave-grpc-protobuf-shaded:jar:0.9.7
+- io.grpc:grpc-protobuf:jar:1.2.0:compile
| +- io.grpc:grpc-core:jar:1.2.0:compile
| | +- (com.google.guava:guava:jar:14.0-rc1:compile - version managed from 19.0; omitted for duplicate)
| | +- com.google.errorprone:error_prone_annotations:jar:2.0.11:compile
| | +- com.google.code.findbugs:jsr305:jar:3.0.0:compile
| | +- io.grpc:grpc-context:jar:1.2.0:compile
| | - com.google.instrumentation:instrumentation-api:jar:0.3.0:compile
| | - (com.google.code.findbugs:jsr305:jar:3.0.0:compile - omitted for duplicate)
| +- com.google.protobuf:protobuf-java:jar:3.2.0:compile
| +- com.google.guava:guava:jar:14.0-rc1:compile
| +- com.google.protobuf:protobuf-java-util:jar:3.2.0:compile
| | +- (com.google.protobuf:protobuf-java:jar:3.2.0:compile - omitted for duplicate)
| | +- (com.google.guava:guava:jar:14.0-rc1:compile - version managed from 18.0; omitted for duplicate)
| | - com.google.code.gson:gson:jar:2.7:compile
| - io.grpc:grpc-protobuf-lite:jar:1.2.0:compile
| +- (io.grpc:grpc-core:jar:1.2.0:compile - omitted for duplicate)
| - (com.google.guava:guava:jar:14.0-rc1:compile - version managed from 19.0; omitted for duplicate)
+- io.grpc:grpc-stub:jar:1.2.0:compile
| - (io.grpc:grpc-core:jar:1.2.0:compile - omitted for duplicate)
+- org.slf4j:slf4j-log4j12:jar:1.7.21:compile
| +- org.slf4j:slf4j-api:jar:1.7.21:compile
| - log4j:log4j:jar:1.2.17:compile
- junit:junit:jar:4.11:test
- org.hamcrest:hamcrest-core:jar:1.3:test

Solution

Upgrade guava to version 19.0.

Please let me know if you need stack trace or test case to investigate this issue. I can try to provide you more information.

Thanks a lot.

Regards,
Leo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions