Hi,
The problem is that Jersey is currently not resolving T to Person.
Hmm... this is a tricky one to implement.
The generic type that JAXB message body writer for supporting lists of
JAXB elements sees is List<T>. The only way that you can resolve T is
if you know what the concrete class is, and this needs to be done
explicitly via reflection, and is not something that is easy to
support (there is no help in this respect from the Java runtime).
I am wondering if it may be possible to work around this using
GenericEntity [1] and pass the generic entity, or GenericType [2] to
obtain the type required for the former e.g.:
public class ListGenericType<T> extends GenericType<List<T>> {
}
but i would need to think some more about this.
Could you log an issue?
Thanks,
Paul.
[1]
https://jsr311.dev.java.net/nonav/javadoc/javax/ws/rs/core/GenericEntity.html
[2]
https://jersey.dev.java.net/nonav/apidocs/1.1.0-ea/jersey/com/sun/jersey/api/client/GenericType.html
On Jun 26, 2009, at 9:38 AM, testn wrote:
>
> I have a base resource class that looks like this:
>
> public class AbstractResource<T> extends JpaDaoSupport {
> private final Class<T> clazz;
>
> protected AbstractResource(Class<T> clazz)
> {
> this.clazz = clazz;
> }
>
> @GET
> @Produces({"application/xml", "application/json"})
> public List<T> getAll() {
> return this.getJpaTemplate().find("from "+clazz.getName());
> }
> }
>
> and my subclass that looks like
>
> @Path("/Person")
> @Produces("text/plain")
> public class PersonResource extends AbstractResource<Person> {
>
> public PersonResource() {
> super(Person.class);
> }
>
> @GET
> @Produces("application/xml")
> @Path("{userName}")
> public Person getTestReply(@PathParam("userName") String userName) {
> return this.getJpaTemplate().find(Person.class, userName);
> }
> }
>
> when I try to go to http://localhost:9090/abc/Person, it fails with
> error
> message:
> SEVERE: A message body writer for Java type, class
> java.util.ArrayList, and
> MIME media type, application/xml, was not found
>
> Is there any way I can configure Jersey to find methods in base
> class as
> well?
>
>
> Thanks!
> --
> View this message in context: http://n2.nabble.com/Resource-Subclass-tp3160169p3160169.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>