users@jersey.java.net

Re: [Jersey] Resource Subclass

From: testn <test1_at_doramail.com>
Date: Fri, 26 Jun 2009 01:00:47 -0700 (PDT)

after digging more,

        @GET
        @Produces({"application/xml", "application/json"})
        public T getAll() {
                return (T) this.getJpaTemplate().find("from "+clazz.getName()).get(0);
        }
works in the base class... but not this...

        @GET
        @Produces({"application/xml", "application/json"})
        public List<T> getAll() {
                return this.getJpaTemplate().find("from "+clazz.getName());
        }

However, the second one does work when it's in the subclass.


testn wrote:
>
> Don't tihnk so. it works when I moved it to subclass.
>
> Martin Probst wrote:
>>
>>> 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?
>>
>> I think it does find the method and tries to use it, but the method
>> returns an ArrayList<Person>, and Jersey doesn't know how to serialize
>> that to XML. So you need to provide a MessageBodyWriter that can turn
>> the ArrayList<Person> into a meaningful XML document.
>>
>> Martin
>>
>> ---------------------------------------------------------------------
>> 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/Resource-Subclass-tp3160169p3160243.html
Sent from the Jersey mailing list archive at Nabble.com.