Don't know if this is the same issue you are having, but we encountered
JSON compatibility problems after upgrading from Jersey 1 to Jersey 2.
The specific problem we had was with Jackson 2 ignoring
XmlElementWrapper; there are several discussions of this topic you can
find via Google.
We got around it by defining an @Provider JacksonConfig implementing
ContextResolver:
objectMapper = new ObjectMapper();
objectMapper.configure(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME,
true);
final AnnotationIntrospector primary = new
JacksonAnnotationIntrospector();
final AnnotationIntrospector secondary = new
JaxbAnnotationIntrospector(objectMapper.getTypeFactory());
final AnnotationIntrospector pair = new
AnnotationIntrospectorPair(primary, secondary);
objectMapper.setAnnotationIntrospector(pair);
On 2/10/2015 8:11 PM, NBW wrote:
> I'm in the process of migrating an application which is currently
> deployed to EE6/Glassfish 3.1.2.2 and uses a simple JAXBContextResolver
> to provide to contexts for JSON (de)serialization. One context uses
> mapped and the other natural. The mapped context configures 'arrays' and
> sets root unwrapping true. The natural context simply sets root
> unwrapping to true.
>
> So far, deploying to Glassfish 4.1, I've tried both the default MOXy and
> Jackson. With MOXy I set up a simple MoxyJsonConfig, created a
> ContextResolver for it and registered the resolver with my Application
> class. With Jackson I registered the JacksonFeature and an ObjectMapper
> @Provider setting features as appeared appropriate. Neither approach was
> able to generate the same JSON output as I was getting with GF 3.1.2.2 /
> Jersey 1.11.
>
> Has anyone gone down this path? Is there a simple drop in replacement
> for these modes in Jersey 2 that I'm just missing?
>
> Thanks,
>
> -Noah
>
--
Guy Rouillier
---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com