cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wei Zhang (JIRA)" <>
Subject [jira] [Created] (CXF-6380) Context provider not working
Date Thu, 30 Apr 2015 02:02:05 GMT
Wei Zhang created CXF-6380:

             Summary: Context provider not working
                 Key: CXF-6380
             Project: CXF
          Issue Type: Bug
          Components: JAX-RS
    Affects Versions: 3.0.3
            Reporter: Wei Zhang

Come from a TCK test. In the test, there is an Entity provider with readFrom returns null.
And a context provider which provides a customized JAXBContext and corresponding  Marshaller
and unmarshaller.
public class JaxbContextProvider
    implements ContextResolver
    public JAXBContext getContext(Class type)
        JAXBContext ctx = new MyJaxbContext();
        return ctx;
    public volatile Object getContext(Class clazz)
        return getContext(clazz);

public class MyJaxbProvider
    implements MessageBodyReader, MessageBodyWriter


    public JAXBElement readFrom(Class type, Type genericType, Annotation annotations[], MediaType
mediatype, MultivaluedMap multivaluedmap, InputStream inputstream)
        throws IOException, WebApplicationException
        return null;

And there is  a resource class which returns a JAXBElement object.
public class Resource
    public JAXBElement jaxb(JAXBElement jaxb)
        return jaxb;
When accessing this resource, I found only the entity provider is working, and  null response(status
code 204) is returned. And the context Provider was not working(getContext method defined
in this provider was not triggered at all).
When removing this entity provider from our test application, the context provider is working
and an JAXB object is mashalled to the response(with status code 200).

In the JSR339, I only found following declaration about the usage of entity provider and context

See 4.2.4 
An implementation MUST support application-provided entity providers and MUST use those in
to its own pre-packaged providers when either could handle the same request. More precisely,
4 in Section 4.2.1 and step 5 in Section 4.2.2 MUST prefer application-provided over pre-packaged

In my understanding, if user only defines its own context provider without customized entity
provider, application providered context provider should be preferred over CXF default implmentation
of entity provider.

And this usage of both customized context provider and customerized entity provider, which
provider should be prefered is out of specification definition.

But when testing on Apache/Jersy with this test applicatoin, response with status code 200
is returned.

Would you please advice if this can be a defect in CXF, or you think it's out of specification

This message was sent by Atlassian JIRA

View raw message