quarkiverse / quarkus-google-cloud-services

Google Cloud Services Quarkus Extensions
https://docs.quarkiverse.io/quarkus-google-cloud-services/main/index.html
Apache License 2.0
54 stars 34 forks source link

NoClassDefFoundError for TimeConversionUtils after Upgrading to Quarkus LTS v3.15.0 and Pubsub v2.12.1 #684

Open iqnev opened 1 month ago

iqnev commented 1 month ago

Hello,

I've recently upgraded our project from Quarkus version 3.8.5 to the latest LTS version 3.15.0. Additionally, I updated io.quarkiverse.googlecloudservices:quarkus-google-cloud-pubsub to its latest version, v2.12.1.

During application testing, I encountered the following error indicating a missing class:

java.lang.NoClassDefFoundError: 
com/google/api/gax/util/TimeConversionUtils
    at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider$Builder.setKeepAliveTime(InstantiatingGrpcChannelProvider.java:726)
    at com.google.cloud.pubsub.v1.Subscriber$Builder.<init>(Subscriber.java:488)
    at com.google.cloud.pubsub.v1.Subscriber.newBuilder(Subscriber.java:234)
    ...

image

It seems that the class TimeConversionUtils is not available in the com.google.api.gax.util package.

Additionally, in the process of upgrading, the google-cloud-sdk dependency was updated from version 26.43.0 to 26.45.0 in this PR https://github.com/quarkiverse/quarkus-google-cloud-services/pull/667/files

From this upgrade, google-cloud-pubsub was updated to 1.132.1, but the dependency tree still shows com.google.cloud:google-cloud-pubsub:jar:1.130.1 under google-cloud-pubsub:jar:2.12. Here is a snippet of the relevant part of the dependency tree:

[INFO] +- io.quarkiverse.googlecloudservices:quarkus-google-cloud-pubsub:jar:2.12.1:compile
[INFO] |  +- io.quarkiverse.googlecloudservices:quarkus-google-cloud-common:jar:2.12.1:compile
[INFO] |  |  +- io.quarkus.security:quarkus-security:jar:2.1.0:compile
[INFO] |  |  +- com.google.auth:google-auth-library-oauth2-http:jar:1.24.1:compile
[INFO] |  |  +- com.google.cloud:google-cloud-core:jar:2.42.0:compile
[INFO] |  |  +- org.jboss.logging:commons-logging-jboss-logging:jar:1.0.0.Final:compile
[INFO] |  |  \- org.graalvm.sdk:nativeimage:jar:23.1.2:compile
[INFO] |  |     \- org.graalvm.sdk:word:jar:23.1.2:compile
[INFO] |  +- io.quarkiverse.googlecloudservices:quarkus-google-cloud-common-grpc:jar:2.12.1:compile
[INFO] |  |  +- com.google.api:gax-grpc:jar:2.52.0:compile
[INFO] |  |  \- io.grpc:grpc-netty:jar:1.65.1:compile
[INFO] |  |     +- io.netty:netty-codec-http2:jar:4.1.111.Final:compile
[INFO] |  |     |  +- io.netty:netty-common:jar:4.1.111.Final:compile
[INFO] |  |     |  +- io.netty:netty-buffer:jar:4.1.111.Final:compile
[INFO] |  |     |  +- io.netty:netty-transport:jar:4.1.111.Final:compile
[INFO] |  |     |  +- io.netty:netty-codec:jar:4.1.111.Final:compile
[INFO] |  |     |  +- io.netty:netty-handler:jar:4.1.111.Final:compile
[INFO] |  |     |  \- io.netty:netty-codec-http:jar:4.1.111.Final:compile
[INFO] |  |     +- io.netty:netty-handler-proxy:jar:4.1.111.Final:compile
[INFO] |  |     |  \- io.netty:netty-codec-socks:jar:4.1.111.Final:compile
[INFO] |  |     \- io.netty:netty-transport-native-unix-common:jar:4.1.111.Final:compile
[INFO] |  +- com.google.cloud:google-cloud-pubsub:jar:1.130.1:compile
[INFO] |  |  +- io.grpc:grpc-api:jar:1.65.1:compile
[INFO] |  |  +- io.grpc:grpc-stub:jar:1.65.1:compile
[INFO] |  |  +- io.grpc:grpc-protobuf:jar:1.65.1:compile
[INFO] |  |  +- io.grpc:grpc-protobuf-lite:jar:1.65.1:runtime
[INFO] |  |  +- com.google.api:api-common:jar:2.32.0:compile
[INFO] |  |  +- com.google.j2objc:j2objc-annotations:jar:2.8:compile
[INFO] |  |  +- com.google.protobuf:protobuf-java:jar:3.25.3:compile
[INFO] |  |  +- com.google.api.grpc:proto-google-common-protos:jar:2.41.0:compile
[INFO] |  |  +- com.google.auth:google-auth-library-credentials:jar:1.23.0:compile
[INFO] |  |  +- com.google.http-client:google-http-client-gson:jar:1.44.2:compile
[INFO] |  |  +- com.google.api.grpc:proto-google-cloud-pubsub-v1:jar:1.112.1:compile
[INFO] |  |  +- com.google.api.grpc:proto-google-iam-v1:jar:1.35.0:compile
[INFO] |  |  +- com.google.guava:guava:jar:33.2.1-jre:compile
[INFO] |  |  +- com.google.guava:failureaccess:jar:1.0.1:compile
[INFO] |  |  +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile
[INFO] |  |  +- com.google.api:gax:jar:2.49.0:compile
[INFO] |  |  +- io.grpc:grpc-inprocess:jar:1.65.1:compile
[INFO] |  |  +- io.grpc:grpc-core:jar:1.65.1:compile
[INFO] |  |  +- com.google.android:annotations:jar:4.1.1.4:runtime
[INFO] |  |  +- io.grpc:grpc-alts:jar:1.65.1:compile
[INFO] |  |  +- io.grpc:grpc-grpclb:jar:1.65.1:compile
[INFO] |  |  +- org.conscrypt:conscrypt-openjdk-uber:jar:2.5.2:compile
[INFO] |  |  +- io.grpc:grpc-auth:jar:1.65.1:compile
[INFO] |  |  +- io.grpc:grpc-util:jar:1.65.1:runtime
[INFO] |  |  +- io.perfmark:perfmark-api:jar:0.27.0:runtime
[INFO] |  |  +- io.grpc:grpc-googleapis:jar:1.65.1:runtime
[INFO] |  |  +- io.grpc:grpc-xds:jar:1.65.1:runtime
[INFO] |  |  +- io.opencensus:opencensus-proto:jar:0.2.0:runtime
[INFO] |  |  +- io.grpc:grpc-services:jar:1.65.1:runtime
[INFO] |  |  +- com.google.re2j:re2j:jar:1.7:runtime
[INFO] |  |  +- com.google.api:gax-httpjson:jar:2.49.0:compile
[INFO] |  |  +- com.google.code.gson:gson:jar:2.11.0:compile
[INFO] |  |  +- com.google.protobuf:protobuf-java-util:jar:3.25.3:compile
[INFO] |  |  +- org.threeten:threetenbp:jar:1.6.9:compile
[INFO] |  |  +- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] |  |  +- io.opencensus:opencensus-api:jar:0.31.1:compile
[INFO] |  |  +- io.grpc:grpc-context:jar:1.65.1:compile
[INFO] |  |  +- com.google.errorprone:error_prone_annotations:jar:2.30.0:compile
[INFO] |  |  +- com.google.auto.value:auto-value-annotations:jar:1.10.4:compile
[INFO] |  |  +- com.google.http-client:google-http-client:jar:1.44.2:compile
[INFO] |  |  +- org.apache.httpcomponents:httpclient:jar:4.5.14:runtime
[INFO] |  |  +- org.apache.httpcomponents:httpcore:jar:4.4.16:runtime
[INFO] |  |  \- io.opencensus:opencensus-contrib-http-util:jar:0.31.1:runtime

Could this be a mismatch or an outdated dependency causing the issue? Any suggestions on how to resolve this error would be highly appreciated!

Thank you for your help!

iqnev commented 1 month ago

I forcibly updated the com.google.api:gax dependency in my project by specifying the version directly in the pom.xml file with the following configuration:

      <dependency>
        <groupId>com.google.api</groupId>
        <artifactId>gax</artifactId>
        <version>2.52.0</version>
      </dependency>

This update resolved the issue described above. However, I'm unclear why the com.google.api:gax:jar was initially set to version 2.49.0. Any insights into why this older version was used would be appreciated.

loicmathieu commented 1 month ago

Hi this dependency is not set to 2.49.0 manually in this repo, there must be a dependency divergence issue somewhere.

iqnev commented 1 month ago

Hi @loicmathieu 2.49.0 comes from com.google.cloud:google-cloud-pubsub:jar:1.130.1
image

Also the google-cloud-pubsub delivers the relevant version

<!-- https://mvnrepository.com/artifact/com.google.cloud/google-cloud-pubsub -->
<dependency>
    <groupId>com.google.cloud</groupId>
    <artifactId>google-cloud-pubsub</artifactId>
    <version>1.130.1</version>
</dependency>

image

But it is strange

loicmathieu commented 1 month ago

Dependency convergence are a little more complex than that, something else in the dependency tree makes Maven resolve it to the wrong version.

loicmathieu commented 1 month ago

@iqnev I updated to Quarkus 3.16 and checked, and it is correctly resolved to the right version. Some dependency divergence should exist in Quarkus 3.15.