Я получаю эту ошибку только в производственной среде (но не в eclipse).
Найдите пример кода для справки:
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
Client client = Client.create();
WebResource webResource = client.resource(url);
ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON)
.header("username", "user")
.header("password", "pass")
.post(ClientResponse.class);
if (response.getStatus() != 200) {
throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());
}
String output = response.getEntity(String.class);
Также я получаю исключение что-то вроде ниже. Не могли бы вы просмотреть это:
com.sun.jersey.api.client.ClientHandlerException: A message body reader for Java class java.lang.String, and Java type class java.lang.String, and MIME media type application/json was not found
at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:549)
at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:506)
в строке:
String output = response.getEntity(String.class);
Также, пожалуйста, найдите зависимости в class Path моего проекта
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry exported="true" kind="lib" path="lib/activation.jar"/>
<classpathentry exported="true" kind="lib" path="lib/antlr-2.7.5H3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/asm.jar"/>
<classpathentry exported="true" kind="lib" path="lib/c3p0-0.9.1.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/cglib-2.1.3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-collections.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-httpclient-3.1-rc1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-io-2.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-lang-2.3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-logging.jar"/>
<classpathentry exported="true" kind="lib" path="lib/dom.jar"/>
<classpathentry exported="true" kind="lib" path="lib/dom4j-1.6.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/ehcache-1.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/hibernate3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jackson-core-asl-1.7.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jackson-jaxrs-1.7.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jackson-mapper-asl-1.7.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jackson-xc-1.7.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/java-json.jar"/>
<classpathentry exported="true" kind="lib" path="lib/javassist-3.18.1-GA.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jaxb-api.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jaxb-impl.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jaxb1-impl.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jaxrpc-api.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jaxrpc-impl.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jaxrpc-spi.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jaxws-rt.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jersey-apache-client-1.8.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jersey-atom-abdera-1.8.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jersey-bundle-1.10-b01.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jersey-client-1.8.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jersey-core-1.8.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jersey-guice-1.8.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jersey-json-1.8.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jersey-server-1.8.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jersey-simple-server-1.8.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jta.jar"/>
<classpathentry exported="true" kind="lib" path="lib/log4j-1.2.8.jar"/>
<classpathentry exported="true" kind="lib" path="lib/mail.jar"/>
<classpathentry exported="true" kind="lib" path="lib/mysql-connector-java-5.1.18-bin.jar"/>
<classpathentry exported="true" kind="lib" path="lib/poi-3.8-20120326.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>