Hi all,
it would be nice if some of you could help me to solve the following
problem.
If think that JAXB based JSON support with the Jersey 1.17 Client API
does not work while posting Parameter objects.
The code in the attachement delivers
415
[text/html;charset=utf-8]
Mai 02, 2013 10:11:13 AM com.sun.jersey.api.client.ClientResponse
getEntity
SEVERE: A message body reader for Java class common.Pair, and Java
type class common.Pair, and MIME media type text/html; charset=utf-8 was
not found
Mai 02, 2013 10:11:13 AM com.sun.jersey.api.client.ClientResponse
getEntity
SEVERE: The registered message body readers compatible with the MIME
media type are:
/ ->
com.sun.jersey.core.impl.provider.entity.FormProvider
com.sun.jersey.core.impl.provider.entity.StringProvider
com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
com.sun.jersey.core.impl.provider.entity.FileProvider
com.sun.jersey.core.impl.provider.entity.InputStreamProvider
com.sun.jersey.core.impl.provider.entity.DataSourceProvider
com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General
com.sun.jersey.core.impl.provider.entity.ReaderProvider
com.sun.jersey.core.impl.provider.entity.DocumentProvider
com.sun.jersey.core.impl.provider.entity.SourceProvider$StreamSourceReader
com.sun.jersey.core.impl.provider.entity.SourceProvider$SAXSourceReader
com.sun.jersey.core.impl.provider.entity.SourceProvider$DOMSourceReader
com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider$General
com.sun.jersey.json.impl.provider.entity.JSONArrayProvider$General
com.sun.jersey.json.impl.provider.entity.JSONObjectProvider$General
com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General
com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General
com.sun.jersey.core.impl.provider.entity.XMLRootObjectProvider$General
com.sun.jersey.core.impl.provider.entity.EntityHolderReader
com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$General
com.sun.jersey.json.impl.provider.entity.JSONListElementProvider$General
com.sun.jersey.json.impl.provider.entity.JacksonProviderProxy
Exception in thread "main"
com.sun.jersey.api.client.ClientHandlerException: A message body reader
for Java class common.Pair, and Java type class common.Pair, and MIME
media type text/html; charset=utf-8 was not found
at
com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:561)
at
com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:517)
at client.ComputeConcat.main(ComputeConcat.java:41)
Line 41 is the getEntity call.
If changing @Consumes({MediaType.APPLICATION_JSON}) to
@Consumes({MediaType.APPLICATION_XML}) for the concat method, then the
code operates and delivers
200
[application/json]
Hello, World!
However, then the input pair object is sent as XML and not as JSON
serialization. It seems like the Jersy Client does not automatically
serialize the pair object to JSON but only to XML, although imho it should.
Please note, while having all set JSON as in the attached code the
commented curl call operates as desired, sends JSON and receives JSON.
Do I make any mistakes? Btw., currently I have all jars of Jersey in the
classpath.
Many thanks for any suggestions,
--
Christian Bachmaier
chris_at_infosun.fim.uni-passau.de