karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@code-house.org
Subject Re: JacksonJaxbJsonProvider doesn't work properly after upgrading CXF to 3.x
Date Sun, 06 May 2018 23:59:27 GMT
Hey Neehal,
Have you checked if you have, by accident, two different versions of JAXB in runtime? One
of reasons why annotations get ignored is class loading.

Kind regards,
Lukasz

> On 3 May 2018, at 11:39, Neehal <nshaikh@actiance.com> wrote:
> 
> Hi,
> I have karaf v4.1.5 and have installed CXF v3.2.2. What I notice is that, my
> jackson serialization only works if I remove any XML JAXB annotations from
> the response class. 
> I have my JacksonJaxbJsonProvider configured in the blueprint as a provider.
> 
> <bean id="jsonProvider" class="com.xyz.cxf.CustomJacksonJaxbJsonProvider">
> 	</bean>
> <jaxrs:server id="xyz" address="/cxf">
> 		<jaxrs:serviceBeans>
> 			<ref component-id="applicationWebService" />
> 		</jaxrs:serviceBeans>
> 		<jaxrs:providers>
> 			<ref component-id="jsonProvider" />  
> 		</jaxrs:providers>
> 	</jaxrs:server>
> 
> My 'CustomJacksonJaxbJsonProvider' extends 'JacksonJaxbJsonProvider', and I
> have configured the following:
> 
> ObjectMapper mapper = new ObjectMapper();
> mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
> mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
> mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
> setMapper(mapper);
> setAnnotationsToUse(DEFAULT_ANNOTATIONS);
> 
> 
> The above take effect only if do not have any JAXB annotations(e.g.
> @XmlRootElement) in the response class. 
> My response has a map that shows like,
> { entry: { key: "xyz", value: "abc"}}, instead of ,
> { "xyz" : "abc" } 
> 
> This was not a problem with my earlier CXF v2.7.13 on Karaf. Has anyone else
> faced a similar problem?
> 
> Regards,
> Neehal.
> 
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Mime
View raw message