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)