google-cloud-java: NoClassDefFoundError: com/google/api/gax/retrying/RetrySettings at LanguageServiceSettings
Hi I’ve created a java class with a main method in order to test NLP API.
Extract of my pom.xml:
<!-- Google Cloud Natural Language API -->
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-language</artifactId>
<version>0.19.0-beta</version>
</dependency>
In my GoogleTest java class I test others google APIs.
My method:
public static void myNaturalLanguageTest() throws IOException {
//Instanciate a client
LanguageServiceClient language = LanguageServiceClient.create();
//Text to analyze
String text = "Hello world";
Document doc = Document.newBuilder().setContent(text).setType(Type.PLAIN_TEXT).build();
//Detect the sentiment
//TODO we obtained an error for the moment - 29-03-2017
//java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
Sentiment sentiment = language.analyzeSentiment(doc).getDocumentSentiment();
System.out.printf("Text: %s%n", text);
System.out.printf("Sentiment: %s, %s%n", sentiment.getScore(), sentiment.getMagnitude());
}
When I execute my java class, I obtain a NoCLassDefFoundError:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/api/gax/retrying/RetrySettings
at com.google.cloud.language.spi.v1.LanguageServiceSettings$Builder.<clinit>(LanguageServiceSettings.java:245)
at com.google.cloud.language.spi.v1.LanguageServiceSettings.defaultBuilder(LanguageServiceSettings.java:189)
at com.google.cloud.language.spi.v1.LanguageServiceClient.create(LanguageServiceClient.java:114)
at com.xxx.product.xxx.google.test.GoogleTest.myNaturalLanguageTest(GoogleTest.java:396)
at com.xxx.product.moderation.google.test.GoogleTest.main(GoogleTest.java:259)
Caused by: java.lang.ClassNotFoundException: com.google.api.gax.retrying.RetrySettings
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)
... 5 more
Thanks.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (7 by maintainers)
Have you figured out the right setup for netty? I’m having the same issue here trying to use Pubsub
Now I think you are seeing the issue noted in https://github.com/GoogleCloudPlatform/google-cloud-java/issues/2050 . Add an explicit declaration of the versions of google-auth-library-credentials and google-auth-library-oauth2-http (they need to be at least 0.6.0 to avoid the
ServiceAccountSigner
problem).