question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jersey, JAXB and Jackson ignore XmlTransient in 1.4 but honour it in 1.3.5

See original GitHub issue

In upgrading from spring-boot 1.3.5 including the spring-boot-starter-jersey it went from working to getting this exception:

org.glassfish.jersey.server.internal.process.MappableException: com.fasterxml.jackson.databind.JsonMappingException: Infinite recursion

due to my User > accounts > owner > accounts etc. recursion

In 1.3.5 it honors @XmlTransient but with 1.4.0.SNAPSHOT it doesn’t

According to this: http://wiki.fasterxml.com/JacksonJAXBAnnotations

the jackson-xc library should be added and the JAXB annotation introspector should be registered

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jasoncarreiracommented, Aug 15, 2017

I simplified this a bit too much to get the stack trace, but if you look at the JSON output from calling http://localhost:8080/organizations first with the 1.3.5 then with the 1.4.0 you can see that @XmlTransient is not being honored. Just switch the comments on the spring-boot-version property and parent version in the top-level maven pom.xml.

Here’s some SQL to create sample data:

INSERT INTO `sample`.`organizations` (`id`, `name`) VALUES ('a', 'a');
INSERT INTO `sample`.`organizations` (`id`, `name`, `parent_id`) VALUES ('b', 'b', 'a');
INSERT INTO `sample`.`organizations` (`id`, `name`, `parent_id`) VALUES ('c', 'c', 'a');
INSERT INTO `sample`.`organizations` (`id`, `name`, `parent_id`) VALUES ('d', 'd', 'b');
INSERT INTO `sample`.`organizations` (`id`, `name`, `parent_id`) VALUES ('e', 'e', 'c');

api-sample.zip

0reactions
jasoncarreiracommented, Jul 4, 2016

Cool, thanks! I just looked for why Jersey wouldn’t honor JAXB annotations and that was what came up. As long as it produces the same as 1.3.5 I’ll be happy.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jersey omits XmlTransient annotation during serialization
In Jackson 2.x it can be achieved with a proper AnnotationIntrospector . Supporting both Jackson and JAXB annotations.
Read more >
JAXB Release Documentation - Java EE
Launching xjc; 1.3. xjc Syntax; 1.4. ... JAXB-794 - Classes annotated with @XmlTransient are still mapped to XML ... Regression in Jersey JSON...
Read more >
[Jersey] JAXB annotations are ignored while serializing to JSON
I have JAXB annotations on my representations and I'm facing an issue getting Jersey to honor those annotations while serializing to JSON.
Read more >
Jackson Ignore Properties on Marshalling - Baeldung
This tutorial will show how to ignore certain fields when serializing an object to JSON using Jackson 2.x.
Read more >
replace Jackson specific @JsonIgnore annotation with JAXB ...
replace Jackson specific @JsonIgnore annotation with JAXB @XmlTransient on NeutronObject's setTenantID(Uuid tenantID), but note setTenantID(String tenantID) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found