users@jersey.java.net

Re: [Jersey] Collections and JAXB support

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Wed, 25 Mar 2009 09:09:18 -0500

I'm guessing that you might need to use GenericEntity to capture the
generic type of the collection. If the method returns say
List<Something> directly then the runtime can determine the generic
type (Something) but if it returns Response then the generic type is
lost due to type erasure.

See example 1 in the javadoc:

https://jsr311.dev.java.net/nonav/releases/1.0/javax/ws/rs/core/GenericEntity.html

Marc.

On Mar 25, 2009, at 8:58 AM, Tim Williams wrote:

> Writing a collection out works fine if I return the collection
> directly as in the JAXB examples. However, if I use
> Response.ok(collection).build() I get the dreaded 'no message body
> writer' error. Ultimately, I'm just using the Response object because
> I need to write cache-control headers, so if there's another way to do
> that while returning the collection, I'd be ok with that too.
> Thanks,
> --tim
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>