Home java.net.ConnectException when trying to connect watson toneanalyser in java spring
Reply: 0

java.net.ConnectException when trying to connect watson toneanalyser in java spring

user2924
1#
user2924 Published in June 19, 2018, 11:55 pm

I'm using watson toneanalyser to detect dominant tone from a text. I get the result in android but in java spring i get the following error when i call the get Tone function.

Error Log

 HTTP Status 500 - Request processing failed; nested exception is java.lang.RuntimeException: java.net.ConnectException: Failed to connect to gateway.watsonplatform.net/169.48.66.222:443
 type Exception report

  message Request processing failed; nested exception is java.lang.RuntimeException: java.net.ConnectException: Failed to connect to gateway.watsonplatform.net/169.48.66.222:443

 description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.RuntimeException: java.net.ConnectException: Failed to connect to gateway.watsonplatform.net/169.48.66.222:443
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
root cause

java.lang.RuntimeException: java.net.ConnectException: Failed to connect to gateway.watsonplatform.net/169.48.66.222:443
com.ibm.watson.developer_cloud.service.WatsonService$1.execute(WatsonService.java:176)
com.futuro.textmining.controller.MyController.getDominantEmotion(MyController.java:55)
com.futuro.textmining.controller.MyController.loadIndexLogin(MyController.java:86)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)

My Code

 private String getDominantEmotion(String text){
     final String VERSION_DATE = "2018-02-14";
     ToneAnalyzer toneAnalyzer = new ToneAnalyzer(VERSION_DATE);
 toneAnalyzer.setUsernameAndPassword("80ff86fc-1329-46c1-9b51-45dda8d987e9", "WnQUuZcjVfLP");

      ToneOptions options = new ToneOptions.Builder().text(text).sentences(false).build();
        DocumentAnalysis documentAnalysis = toneAnalyzer.tone(options).execute().getDocumentTone();
        List<ToneScore> toneScores = documentAnalysis.getToneCategories().get(0).getTones();

        double maxScore = toneScores.get(0).getScore();
        String dominantTone = toneScores.get(0).getToneId();
        for(ToneScore toneScore : toneScores){
            if(toneScore.getScore() > maxScore){
                maxScore = toneScore.getScore();
                dominantTone = toneScore.getToneName();
            }
      }

     return dominantTone;
 }
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.308246 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO