user5480389
user5480389

Reputation:

Trying to call Watson Translation Service

I am trying to call the IBM Watson Service via REST call in Java. I have got an Web Project in Eclipse which is published via Bluemix Tools. I also use the .jar Files. But when i´m trying a simple code like:

LanguageTranslation service = new LanguageTranslation();
service.setUsernameAndPassword("{username}","{password}");

List <IdentifiedLanguage> langs = service.identify("this is a test");
System.out.println(langs);

I get this exception:

Unable to extract the trust manager on okhttp3.internal.Platform@ab895790, sslSocketFactory is class com.ibm.jsse2.SSLSocketFactoryImpl
[WARNING ] Application {http://webapp.aw/}ResourceServlet has thrown exception, unwinding now
[WARNING ] Exception in handleFault on interceptor org.apache.cxf.jaxrs.interceptor.JAXRSDefaultFaultOutInterceptor@ac51d486
Unable to extract the trust manager on okhttp3.internal.Platform@ab895790, sslSocketFactory is class com.ibm.jsse2.SSLSocketFactoryImpl
Unable to extract the trust manager on okhttp3.internal.Platform@ab895790, sslSocketFactory is class com.ibm.jsse2.SSLSocketFactoryImpl

Upvotes: 1

Views: 302

Answers (2)

jim conallen
jim conallen

Reputation: 16

There seems to be some incompatibility with the JVM used on Bluemix and this latest (3.0.0.RC1) version of the library.

I can run the sample code locally just fine. Just not on Bluemix.

My workaround is to use the older 2.10 version of the library:

https://github.com/watson-developer-cloud/java-sdk/releases/tag/java-sdk-2.10.0

Everything works fine there (however you need to remove the .execute() from the end of the translate call to be compatible with older library).

Upvotes: 0

far
far

Reputation: 129

I think you may have an outdated JAR file. Can you try downloading the latest version from here.

Once you have done that, add the JAR file to the project's build path, and try this:

LanguageTranslation service = new LanguageTranslation();
service.setUsernameAndPassword("username", "password");

ServiceCall<List<IdentifiedLanguage>> langs = service.identify("this is a test");
System.out.println(langs.execute());

Upvotes: 1

Related Questions