users@jersey.java.net

[Jersey] Contex Resolver not resolving every registered class

From: <reaganej_at_gmail.com>
Date: Wed, 19 Oct 2011 14:52:17 +0000 (GMT)

Hello,
   I have a JSON JAXB context resolve like
    private final Class[] cTypes = {XCollection.class, Bill.class....};
    
    public JAXBContextResolver() throws Exception {
        this.types = new HashSet(Arrays.asList(cTypes));
        this.context = new
JSONJAXBContext(JSONConfiguration.natural().build(), cTypes);
    }
    
    public JAXBContext getContext(Class<?> objectType) {
        return (types.contains(objectType)) ? context : null;
    }

On the server side Jersey sends the request to my remote method and it
gets a list of Bills. When I send a single Bill object back (e.g.
public Bill getBill()...) then I get a server error saying a message
body writter cannot be found. If I move the Bill class out of its
current EJB project and copy it into a different EJB project I can get
the Bill back just fine as XML.

    Additionally when I register a breakpoint on glassfish and attach
my netbeans debugger to the getContext Method, the break point is never
gets hit.

I am wondering my my context resolver, which is in a separate web
project serving up multiple bean web services, doesn't get called to
provide for the Bill class which I have registered but will provide say
a Payment class which is a different bean?

   I know I can run my Bill class through jaxb and have successfully
marshalled/unmarshalled it with jaxb.

   I have added a jersey logging filter and I can see valid xml sent to
the server when doing a put request but then get a response back of
415, which again leads me to believe that my context resolver isn't
being used.

   Is there a way to trace through and see exactly where I am getting
exceptions at?