2

I'm trying to use the Google Cloud Storage SDK for Java into my Spring application.

Using Maven I've added it to my dependencies:

<dependency> <groupId>com.google.cloud</groupId> <artifactId>google-cloud-storage</artifactId> <version>1.31.0</version> </dependency> 

Then I try to initialize the Storage client with:

 client = StorageOptions.newBuilder() .setCredentials(ServiceAccountCredentials.fromStream(new ClassPathResource("/my/path/to.json").getInputStream())) .build() .getService(); 

but an error occurs

java.lang.NoSuchMethodError: com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient$Builder.setBatchPath 

I've noticed that in my google-api-client-1.23.0.jar libray loaded as dependency no setBatchPath was present.

I've tried to find the issue browsing on web but without fortune. I cannot understand which library (and version) I need to install in order to make it works.

    2 Answers 2

    4

    Eventually I solved, there was a library duplication between my Web Application and Its Business Layer Jar component (I have a multi-module Project).

    What I cannot understand is why there was a call to a non-existing method (AbstractGoogleJsonClient$Builder.setBatchPath) that was solved in this way.

    In google-api-client-1.20.0.jar that method does not exists nor in google-api-client-1.23.0.jar

      0

      Try reading this, and then you may be able to work around the error.

        Start asking to get answers

        Find the answer to your question by asking.

        Ask question

        Explore related questions

        See similar questions with these tags.