Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jersey Client API Exception Handling issue

 
PankajKumar jaiswal
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic