Hi everyone,

I am having trouble upgrading to CXF 3.4.1 from version 3.1.7

The issue is that the default JAXBElementProvider is being used instead of
the custom JAXBElementTypedProvider configured in my
JAXRSServerFactoryBean.setProviders() call.

The code in question from
https://github.com/apache/cxf/blob/master/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
:

protected static void initFactory(ProviderFactory factory) {
// ensure to not load providers not available in a module environment if
not needed
factory.setProviders(false,
false,
new BinaryDataProvider<Object>(),
new SourceProvider<Object>(),
DATA_SOURCE_PROVIDER_CLASS.tryCreateInstance(factory.getBus()),
new FormEncodingProvider<Object>(),
new StringTextProvider(),
new PrimitiveTextProvider<Object>(),
JAXB_PROVIDER_CLASS.tryCreateInstance(factory.getBus()),
JAXB_ELEMENT_PROVIDER_CLASS.tryCreateInstance(factory.getBus()),
MULTIPART_PROVIDER_CLASS.tryCreateInstance(factory.getBus()));

sets up a default list of providers.

Both JAXBElement providers are not configured correctly for my purpose
(because they have little to no configuration as expected).

Instead, I have a JAXBElementTypedProvider with a lot of configuration
injected in via the setProviders() call during initialization.

I assumed that because this is a "custom" provider and the
ProviderInfo.custom == true that my configured providers would take
precedence.

This seemed to be true in my trivial test case where I setup a bare bones
client/server application but is not true in the real application.

Upon examination of the state of the real application during initialization
I see that my custom JAXBElement providers sort first in the
MessageBodyWriter list. This is what I expected.

However, when I attempt to call the REST APIs, not only is the default
JAXBElementProvider  used but the MessageBodyWriter ArrayList has a
different sort with the customer JAXBElementTypedProvider after the default.

Is there a better way to control the providers? I'm simply instantiating
the existing JAXBElementTypedProvider class (no sub-classes).

Thanks,

-- 
Stephen Evanchik

Reply via email to