5

I am trying to use google natural language processing api. I add libraries using Maven and add the GOOGLE_APPLICATION_CREDENTIALSas environment variable which is having the path to a JSON file that contains my service account key.

It is giving me an error; Could not find TLS ALPN provider; no working netty-tcnative, Conscrypt, or Jetty NPN/ALPN available

try (LanguageServiceClient language = LanguageServiceClient.create()) {

            // The text to analyze
            String text = "Hello, world!";
            Document doc = Document.newBuilder()
                    .setContent(text).setType(Type.PLAIN_TEXT).build();

            // Detects the sentiment of the text
            Sentiment sentiment = language.analyzeSentiment(doc).getDocumentSentiment();

            System.out.printf("Text: %s%n", text);
            System.out.printf("Sentiment: %s, %s%n", sentiment.getScore(), sentiment.getMagnitude());
        }catch(Exception e){
            System.out.println("Gevindu Error "+ e.getMessage());
        }
denny
  • 197
  • 1
  • 1
  • 11
  • Can you share your pom.xml and commands you used to build? – Justin Sep 18 '19 at 17:43
  • It looks like a [dependencies issue](http://github.com/grpc/grpc-java/issues/4879), could you share your dependencies file (pom.xml) and Maven version you are using? – Noe Romero Sep 27 '19 at 16:20

1 Answers1

0

There isn't much data to be sure about correct answer, but in my case error was because I was using java version 1.8, I change compile properties to 1.9 and error gone:

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.5.1</version>
        <configuration>
            <source>1.9</source>
            <target>1.9</target>
            <optimize>true</optimize>
            <debug>true</debug>
            <encoding>UTF-8</encoding>
        </configuration>
    </plugin>
carduque
  • 188
  • 1
  • 14