I am having difficulty getting CXF to use the MOXy JAX-B implementation when
I have multiple media types.  I have successfully provided the MOXy
implementation with two different JAX-B binding XML files (they call them
OXM files).  Each of the two supports a different media type.   I have two
context resolvers as follows:


@Provider
@Produces({ "application/vnd.foo"})
public class JaxbContextResolverMediaFoo
                implements ContextResolver<JAXBContext> {


@Provider
@Produces({  "application/vnd.bar" })
public class JaxbContextResolverBar
                implements ContextResolver<JAXBContext> {


My problem is that from within a provider,  the call:

resolver = providers.getContextResolver(JAXBContext.class, mediaType);

Does not seem to respect the media type.  Instead is seems to return
whatever context resolver is first in the list of providers.   I have also
created Foo and Bar providers to help diagnose the problem.  My CXF
configuration is as follows:

                <jaxrs:providers>
                        <ref bean="jaxbContextResolverFoo" />
                        <ref bean="jaxbContextResolverBar" />
                        <ref bean="FooXMLProvider" />
                        <ref bean="BarXMLProvider" />
                </jaxrs:providers>

My understanding from the JAX-RS spec is that getContextResolver should
return the context resolver with the most specific media type match that
also returns a JAXBContext from its "getContext" method.

I am unfamiliar with where this sorting of contextresolvers based on media
type takes place, so I can't really tell yet if it is a bug with CXF.

--
View this message in context: 
http://cxf.547215.n5.nabble.com/Issue-with-JAX-RS-providers-getContextResolver-tp5451093p5451093.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to