1

This is my stacktrace of the issue :-

 SEVERE: Unhandled exception
java.lang.NoSuchMethodError: io.opencensus.trace.Span.addMessageEvent(Lio/opencensus/trace/MessageEvent;)V
    at com.google.api.client.http.OpenCensusUtils.recordMessageEvent(OpenCensusUtils.java:222)
    at com.google.api.client.http.OpenCensusUtils.recordSentMessageEvent(OpenCensusUtils.java:190)
    at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:994)
    at com.google.auth.oauth2.ServiceAccountCredentials.refreshAccessToken(ServiceAccountCredentials.java:429)
    at com.google.auth.oauth2.OAuth2Credentials.refresh(OAuth2Credentials.java:157)
    at com.google.auth.oauth2.OAuth2Credentials.getRequestMetadata(OAuth2Credentials.java:145)
    at com.google.auth.http.HttpCredentialsAdapter.initialize(HttpCredentialsAdapter.java:91)
    at com.google.cloud.http.HttpTransportOptions$1.initialize(HttpTransportOptions.java:159)
    at com.google.cloud.http.CensusHttpModule$CensusHttpRequestInitializer.initialize(CensusHttpModule.java:109)
    at com.google.api.client.http.HttpRequestFactory.buildRequest(HttpRequestFactory.java:88)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.buildHttpRequest(AbstractGoogleClientRequest.java:300)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
    at com.google.cloud.storage.spi.v1.HttpStorageRpc.get(HttpStorageRpc.java:436)
    at com.google.cloud.storage.StorageImpl$5.call(StorageImpl.java:244)
    at com.google.cloud.storage.StorageImpl$5.call(StorageImpl.java:241)
    at com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:105)
    at com.google.cloud.RetryHelper.run(RetryHelper.java:76)
    at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:50)
    at com.google.cloud.storage.StorageImpl.get(StorageImpl.java:240)
    at com.google.cloud.storage.StorageImpl.get(StorageImpl.java:258)

This is my dependency tree :-

  +- com.google.apis:google-api-services-compute:jar:beta-rev91-1.23.0:compile
[INFO] |  \- com.google.api-client:google-api-client:jar:1.23.0:compile
[INFO] |     +- com.google.oauth-client:google-oauth-client:jar:1.23.0:compile
[INFO] |     \- com.google.http-client:google-http-client-jackson2:jar:1.23.0:compile
[INFO] |        \- com.fasterxml.jackson.core:jackson-core:jar:2.1.3:compile
[INFO] +- com.infiverve.flint.sdk:flint-sdk:jar:5.0.0.0:provided
[INFO] +- com.google.guava:guava:jar:28.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.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] |  +- org.checkerframework:checker-qual:jar:2.8.1:compile
[INFO] |  +- com.google.errorprone:error_prone_annotations:jar:2.3.2:compile
[INFO] |  +- com.google.j2objc:j2objc-annotations:jar:1.3:compile
[INFO] |  \- org.codehaus.mojo:animal-sniffer-annotations:jar:1.18:compile
[INFO] \- com.google.cloud:google-cloud-storage:jar:1.102.0:compile
[INFO]    +- com.google.cloud:google-cloud-core-http:jar:1.91.3:compile
[INFO]    |  +- com.google.cloud:google-cloud-core:jar:1.91.3:compile
[INFO]    |  |  +- com.google.protobuf:protobuf-java-util:jar:3.10.0:compile
[INFO]    |  |  +- com.google.api.grpc:proto-google-common-protos:jar:1.17.0:compile
[INFO]    |  |  +- com.google.api.grpc:proto-google-iam-v1:jar:0.13.0:compile
[INFO]    |  |  +- org.threeten:threetenbp:jar:1.3.3:compile
[INFO]    |  |  \- com.google.protobuf:protobuf-java:jar:3.10.0:compile
[INFO]    |  +- com.google.auth:google-auth-library-credentials:jar:0.18.0:compile
[INFO]    |  +- com.google.auth:google-auth-library-oauth2-http:jar:0.18.0:compile
[INFO]    |  |  \- com.google.auto.value:auto-value-annotations:jar:1.6.6:compile
[INFO]    |  +- com.google.http-client:google-http-client:jar:1.32.1:compile
[INFO]    |  |  +- org.apache.httpcomponents:httpclient:jar:4.5.10:compile
[INFO]    |  |  |  +- commons-logging:commons-logging:jar:1.2:compile
[INFO]    |  |  |  \- commons-codec:commons-codec:jar:1.11:compile
[INFO]    |  |  \- org.apache.httpcomponents:httpcore:jar:4.4.12:compile
[INFO]    |  +- com.google.http-client:google-http-client-appengine:jar:1.32.1:compile
[INFO]    |  +- com.google.api:gax:jar:1.49.1:compile
[INFO]    |  +- com.google.api:gax-httpjson:jar:0.66.1:compile
[INFO]    |  |  \- com.google.code.gson:gson:jar:2.8.5:compile
[INFO]    |  +- io.opencensus:opencensus-api:jar:0.24.0:compile
[INFO]    |  |  \- io.grpc:grpc-context:jar:1.22.1:compile
[INFO]    |  +- io.opencensus:opencensus-contrib-http-util:jar:0.24.0:compile
[INFO]    |  \- com.google.api:api-common:jar:1.8.1:compile
[INFO]    |     \- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO]    \- com.google.apis:google-api-services-storage:jar:v1-rev20190910-1.30.3:compile

And I'm getting this issue on this line of my code:-

Storage storage = StorageOptions.newBuilder()
                   .setCredentials(ServiceAccountCredentials.fromStream(credentialsInputStream))
                        .setProjectId(flintRequestProjectID)
                        .build().getService();
Blob blob = storage.get(BlobId.of(billingBucketName, billingFileName)); <- (!!THis line of code!!)

I've tried this fix(link provided below) that i found regarding this issue but it did not worked. Link to the fix i found on github and tried

Chris32
  • 4,716
  • 2
  • 18
  • 30
Murli Dhar
  • 11
  • 2
  • I think maybe this is likely a mismatched library version issue. [Here](https://stackoverflow.com/questions/56236363/nosuchmethoderror-optionsbuilder-build-getservice-in-google-cloud-storage) is a similar case which can solve your issue. Otherwise you can also look into this [case](https://stackoverflow.com/questions/55033953/listing-buckets-with-google-cloud-storage-resulting-in-nosuchmethoderror-java-a). Let me know if it worked for you. – Nibrass H Dec 27 '19 at 09:32
  • @NibrassHaider Thanks for the help! But these scenarios you suggested don't meet mine. The class mentioned in the issue is in the "opencensus-api" library and i've used exclusion to get the right version in my dependency still this issue persist. Also this google-cloud-storage dependency is using this library and by default installing 2 different version of it in the maven repo. Any other ideas for the fix would be appreciative. – Murli Dhar Dec 27 '19 at 10:26
  • The line you mentioned that's giving the error is probably because the variable storage is not defined correctly. Try to do in this [way](https://stackoverflow.com/questions/44121510/how-to-read-a-file-from-google-cloud-storage-in-java). – Nibrass H Dec 27 '19 at 11:34
  • The reason for the error was determined to be the cause of the NoSuchModError caused by the failure to find the method [addMessageEvent](https://github.com/census-instrumentation/opencensus-java/blob/master/api/src/main/java/io/opencensus/trace/Span.java) of Span.java, a subfile of the io.opencus.trace package in the OpenCensus library. – Nibrass H Dec 27 '19 at 11:37
  • Please refer to the "Add the changes to your project" section of the [OpenCensus Repository](https://github.com/census-instrumentation/opencensus-java) on your app. After adding the following to the pom.xml, let me know if it worked or not for you. – Nibrass H Dec 27 '19 at 11:38
  • ` io.opencensus opencensus-api 0.24.0 ` – Nibrass H Dec 27 '19 at 11:39
  • @NibrassHaider I've tried this already putting this dependency in my POM. Also the link you suggested for creating storage variable, it is more the same just done in some other way. I tried that too but the issue exists even now. Thanks anyway! – Murli Dhar Dec 27 '19 at 12:12
  • Can you add a minimal reproducible code in order to investigate further? – Nibrass H Dec 30 '19 at 09:28

0 Answers0