我正在尝试使用以下代码建立到HTTPs休息服务的SSL连接。下面的代码在我的本地系统中的webServer tomcat中运行良好。 但是当我尝试在运行webphere的开发环境中部署它时,我的战争是为数不多的其他战争之一。我得到了错误。描述如下。错误发生在httpClient bean中。 我的Bean创建代码:
@Configuration
public class SSLRestConfiguration {
@Bean
public HttpClient httpClient() {
String url = "https:://vm-ab12-cd34";
String trustStorePwd = "changeit";
String trustStore = "src/resources/cacert/cacerts"; // CACert location relative path
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(new FileInputStream(new File(trustStore)), trustStorePwd);
SSLSocketFactory socketFactory = new SSLSocketFactory(new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignStrategy())
.loadKeyMaterial(keyStore,trustStorePwd.toCharArray()).build(), NoopHostnameVerifier.Instance);
HttpClient httpClient = HttpsClient.custom().setSSLSocketFactory(socketFactory).build();
return httpClient;
}
}
我得到的错误如下:
caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate[org.apache.http.client.HttpClient] factory method 'httpClient' threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/http/util/args
.. at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
.. at org.springframework.expression.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)..
有人可以帮助解决为什么它在Application Server上不起作用? 我坚持这个错误,无法前进。
答案 0 :(得分:0)
我已在我的项目中解决了这个问题。在下面发布答案,以便将来可以帮助某人。
希望这有帮助。