users@jersey.java.net

[Jersey] Resource Subclass

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

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.