aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Jersey Client API Exception Handling issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Jersey Client API Exception Handling issue" Watch "Jersey Client API Exception Handling issue" New topic
Author

Jersey Client API Exception Handling issue

PankajKumar jaiswal
Greenhorn

Joined: Aug 13, 2006
Posts: 17
Hi All,

I am trying to write a web service in Jersey, I am facing issue in exception handling at the client program.

Server Code snippet:


Client code snippet:



I am getting following exception in statement "EmpNotFoundException exc = response.getEntity(EmpNotFoundException.class)":
500
Oct 17, 2012 7:27:42 PM com.sun.jersey.api.client.ClientResponse getEntity
SEVERE: A message body reader for Java class com.jd.exception.EmpNotFoundException, and Java type class com.jd.exception.EmpNotFoundException, and MIME media type text/html; charset=utf-8 was not found
Oct 17, 2012 7:27:42 PM 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.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

Exception in thread "main" com.sun.jersey.api.client.ClientHandlerException: A message body reader for Java class com.jd.exception.EmpNotFoundException, and Java type class com.jd.exception.EmpNotFoundException, 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 com.jd.client.EmpClient.main(EmpClient.java:30)

Any help is greatly appreciated.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Jersey Client API Exception Handling issue