REST客户端中出现java异常:找不到contenttype application/json的messagebodyreader
我正在为HTTPSWeb服务构建一个REST客户端。我的代码在eclipse中工作,但在通过JAR执行时失败,出现上述异常。以下是我的代码:
DefaultHttpClient httpClient = new DefaultHttpClient();
Credentials credentials = new UsernamePasswordCredentials(LoginName,Password);
httpClient.getCredentialsProvider().setCredentials(org.apache.http.auth.AuthScope.ANY, credentials);
SSLContext ctx = SSLContext.getInstance("TLS");
X509TrustManager tm = new X509TrustManager()
{
public void checkClientTrusted(X509Certificate[] xcs, String string)
{}
public void checkServerTrusted(X509Certificate[] xcs, String string)
{}
public X509Certificate[] getAcceptedIssuers()
{
return null;
}
};
ctx.init(null, new TrustManager[] { tm }, null);
SSLSocketFactory ssf = new SSLSocketFactory(ctx);
ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
httpClient.getConnectionManager().getSchemeRegistry().register(new Scheme("https", ssf, 443));
ClientExecutor clientExecutor = new ApacheHttpClient4Executor(httpClient);
ClientRequest request = new ClientRequest(clientURI + tokenURL, clientExecutor);
request.getQueryParameters().add("loginName", LoginName);
request.getQueryParameters().add("operatorId", OperatorId.toString());
ClientResponse<String> response;
try
{
response = request.get(String.class);
if (response.getStatus() != Status.OK.getStatusCode())
{
System.out.println(("Failure: HTTP Code : " + response.getStatus()));
}
token = response.getEntity().toString();
} catch (Exception e)
{
logger.error(("Failed: Exception=" + e.getMessage()) + " " + e);
}
我正在使用ANT build构建我的Jar。我猜这个问题一定与JAR冲突有关。以下是我正在使用的罐子列表:
commons-codec-1.2。罐子
commons-httpclient-3.1。罐子
commons-io-1.4。罐子
commons-logging-1.0.4。罐子
httpclient-4.0。罐子
httpcore-4.1.2。罐子
jackson-core-asl-1.9.9。罐子
jackson-jaxrs-1.9.9。罐子
jackson-mapper-asl-1.9.9。罐子
jackson-xc-1.9.9。罐子
javassist-3.8.0。加罐
jaxb-api-2.2.3。罐子
jaxb-impl-2.2.4。罐子
jaxrs-api-2.3.5。最终的罐子
jboss-common-core-2.2.14。加罐
jboss-el-1.0_02。CR4。罐子
jboss-logging-spi-2.0.5。加罐
jboss-transaction-api-1.0.1。加罐
jbosscache-core-3.2.5。加罐
jcip-annotations-1.0。罐子
抛弃-1.3.1。罐子
jgroups-2.6.13。加罐
jsr250-api-1.0。罐子
log4j-1.2.15。罐子
邮件-1.4.4。罐子
oauth-20100527。罐子
oauth-provider-20100527。罐子
persistence-api-1.0。罐子
resteasy-atom-provider-2.3.5。最终的罐子
resteasy-cache-core-2.3.5。最终的罐子
resteasy-cdi-2.3.5。最终的罐子
resteasy-crypto-2.3.5。最终的罐子
resteasy-fastinfoset-provider-2.3.5。最终的罐子
resteasy-guice-2.3.5。最终的罐子
resteasy-jackson-provider-2.3.4。最终的罐子
resteasy-jackson-provider-2.3.5。最终的罐子
resteasy-jaxb-provider-2.3.5。最终的罐子
resteasy-jaxrs-2.3.5。最终的罐子
resteasy-jettison-provider-2.3.5。最终的罐子
resteasy-jsapi-2.3.5。最终的罐子
resteasy-links-2.3.5。最终的罐子
resteasy-multipart-provider-2.3.5。最终的罐子
resteasy-oauth-2.3.5。最终的罐子
resteasy-spring-2.3.5。最终的罐子
resteasy-yaml-provider-2.3.5。最终的罐子
扫描符号-1.0.3。罐子
共 (0) 个答案