users@jersey.java.net

Re: [Jersey] Entity provider not getting picked up

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 20 Apr 2009 13:16:02 +0200

Hi,

You need to register the provider in the same way as you register a
root resource class, for example, declare the package where the
MyEntityProvider.class resides.

When you deploy the application there should be a log of what root
resource and provider classes have been discovered if you are using
the package registration configuration.

Paul.

On Apr 20, 2009, at 12:07 PM, Jaka JanĨar wrote:

> I have a resource method:
> --
> @GET
> @Produces(MediaType.APPLICATION_JSON)
> public Object get() {...}
> --
>
> And a custom entity provider:
>
> --
> @Provider
> @Produces(MediaType.APPLICATION_JSON)
> @Consumes(MediaType.APPLICATION_JSON)
> public class MyEntityProvider implements MessageBodyReader<Object>,
> MessageBodyWriter<Object>
> --
>
> But when invoking the method, the entity provider isn't getting called
> at all, and I get the exception:
>
> --
> Apr 20, 2009 12:06:19 PM
> com.sun.jersey.spi.container.ContainerResponse write
> SEVERE: A message body writer for Java type, class java.lang.Object,
> and MIME media type, application/json, was not found
> Apr 20, 2009 12:06:19 PM
> com.sun.jersey.server.impl.application.WebApplicationImpl onException
> SEVERE: Internal server error
> javax.ws.rs.WebApplicationException
> at
> com
> .sun
> .jersey.spi.container.ContainerResponse.write(ContainerResponse.java:
> 241)
> at
> com
> .sun
> .jersey
> .server
> .impl
> .application
> .WebApplicationImpl._handleRequest(WebApplicationImpl.java:689)
> --
>
> Is there anything else I need to do to register it?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>