我正在写一个屈臣氏计划来获取性格特征。但是,我遇到了jar文件问题的错误。
import com.ibm.watson.developer_cloud.personality_insights.v3.PersonalityInsights;
import com.ibm.watson.developer_cloud.personality_insights.v3.model.Profile;
public JSONArray getPersonalityTraitsFromWatson(String text) {
JSONArray retval = null;
PersonalityInsights service = new PersonalityInsights("2016-10-20", "xxxx", "yyyy");
Profile response = service.getProfile(text).execute();
System.out.println("profile: " + response);
return retval;
}
第一个问题是okhttp3。我在JavaNetCookieJar中遇到了一个classnotfound错误。我目前正在使用okhttp3并且缺少javanetcookiejar。我从MVNRepository中获取了okhttp3。
Exception in thread "main" java.lang.NoClassDefFoundError: okhttp3/JavaNetCookieJar
at com.ibm.watson.developer_cloud.service.WatsonService.configureHttpClient(WatsonService.java:137)
at com.ibm.watson.developer_cloud.service.WatsonService.<init>(WatsonService.java:117)
at com.ibm.watson.developer_cloud.personality_insights.v3.PersonalityInsights.<init>(PersonalityInsights.java:52)
at com.ibm.watson.developer_cloud.personality_insights.v3.PersonalityInsights.<init>(PersonalityInsights.java:70)
at com.xyz.social.Watson.getPersonalityTraitsFromWatson(Watson.java:20)
at com.xyz.Testing.UnitTester.startUnitTest(UnitTester.java:1720)
at com.xyz.Testing.UnitTester.main(UnitTester.java:1850)
Caused by: java.lang.ClassNotFoundException: okhttp3.JavaNetCookieJar
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)
... 7 more
我尝试使用“org.apache.servicemix.bundles.okhttp-3.2.0_1.jar”和okhttp3.jar,它清除了JavaNetCookieJar错误但抛出了SSLSocketFactory错误(如下所示)
okhttp3.OkHttpClient $ Builder.sslSocketFactory(Ljavax /净/ SSL / SSLSocketFactory的; Ljavax /净/ SSL / X509TrustManager)
答案 0 :(得分:0)
发现问题,okhttp-urlconnection-3.8.1.jar&amp;需要添加logging-interceptor-3.8.1.jar。这解决了这个问题。