https://jsr311.dev.java.net/nonav/javadoc/javax/ws/rs/ext/ExceptionMapper.html
Is it helps for you? I was not used jersey client , I had used web browser
via a Server resource using it as a unified Exception hander.
Julio Faerman wrote:
>
> Hello,
>
> I need some help understanding the handling of nulls by jersey.
>
> On the server resource method, i try to get a bean from the database
> by id and return it to be JAXB marshalled. When the bean does not
> exist, i return null, generating a 204 response.
> On jersey-client, a NullPointerException is thrown (trace below).
>
> Question 1: Is this correct or i should throw an
> WebApplicationException with status 404 when the bean is not found? It
> sounds wrong having to throw and exception in a non-exceptional case.
>
> Question 2: Shouldn't i get a null from WebResource.get()? is it
> possible or it is a exception i must handle?
>
> Thanks,
> Julio
>
> jersey client exception trace:
> Exception in thread "main" java.lang.NullPointerException
> at
> com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General.isSupported(XMLRootElementProvider.java:89)
> at
> com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.isReadable(AbstractRootElementProvider.java:73)
> at
> com.sun.jersey.core.spi.factory.MessageBodyFactory._getMessageBodyReader(MessageBodyFactory.java:214)
> at
> com.sun.jersey.core.spi.factory.MessageBodyFactory.getMessageBodyReader(MessageBodyFactory.java:200)
> at
> com.sun.jersey.client.impl.urlconnection.URLConnectionClientHandler$URLConnectionResponse.getEntity(URLConnectionClientHandler.java:148)
> at
> com.sun.jersey.client.impl.urlconnection.URLConnectionClientHandler$URLConnectionResponse.getEntity(URLConnectionClientHandler.java:138)
> at com.sun.jersey.api.client.WebResource.handle(WebResource.java:510)
> at com.sun.jersey.api.client.WebResource.get(WebResource.java:140)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>
>
--
View this message in context: http://n2.nabble.com/Null-semantics-tp1664483p1665859.html
Sent from the Jersey mailing list archive at Nabble.com.