[ 
https://issues.apache.org/jira/browse/CXF-6380?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14521519#comment-14521519
 ] 

Sergey Beryozkin commented on CXF-6380:
---------------------------------------

I've confirmed that a registered JaxbContextResolver is called by the default 
CXF JAXB provider. 
See the section 4.3 in the spec: "E.g., an application wishing to provide a 
customized JAXBContext to the *default* JAXB entity
providers would supply a class implementing ContextResolver<JAXBContext> ."

So if MyJaxbProvider is registered - then MyJaxbProvider is called.
I.e the test fails because CXF calls MyJaxbProvider.

The question is - why CXF should not call MyJaxbProvider ?

I don't understand...

> Context provider not working
> ----------------------------
>
>                 Key: CXF-6380
>                 URL: https://issues.apache.org/jira/browse/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.
> @Provider
> 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);
>     }
> }
> @Provider
> 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.
> @Path("resource")
> public class Resource
> {
>     @Path("jaxb")
>     @POST
>     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 provider.
> See 4.2.4 
> An implementation MUST support application-provided entity providers and MUST 
> use those in preference
> to its own pre-packaged providers when either could handle the same request. 
> More precisely, step
> 4 in Section 4.2.1 and step 5 in Section 4.2.2 MUST prefer 
> application-provided over pre-packaged entity
> providers.
> 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 definition.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to