@JacksonXmlElementWrapper Conflicting getter/setter definitions for property
See original GitHub issueHi, I’m using latest release 2.0.1 and I’ve got a problem with serializing/deserializing xml (everything works fine in JSON). I’d like to have such a xml: <output><beanInfo><item><name>name</name></item></beanInfo><beanOther><item><name>name</name></item></beanOther></output>
public class WrapperTest {
public static void main(String[] args) throws JsonGenerationException,
JsonMappingException, IOException {
ObjectMapper mapper = new XmlMapper();
Bean bean = new Bean();
BeanInfo beanInfo = new BeanInfo();
beanInfo.setName("name");
BeanInfo beanOther = new BeanInfo();
beanOther.setName("name");
bean.setBeanInfo(new BeanInfo[] { beanInfo });
bean.setBeanOther(new BeanInfo[] { beanOther });
String output = mapper.writeValueAsString(bean);
System.out.println(output);
}
@JacksonXmlRootElement(localName = "output")
private static class Bean {
private BeanInfo[] beanInfo;
private BeanInfo[] beanOther;
@JacksonXmlElementWrapper(localName = "beanInfo")
@JacksonXmlProperty(localName = "item")
public BeanInfo[] getBeanInfo() {
return beanInfo;
}
@JacksonXmlElementWrapper(localName = "beanInfo")
public void setBeanInfo(BeanInfo[] beanInfo) {
this.beanInfo = beanInfo;
}
@JacksonXmlElementWrapper(localName = "beanOther")
@JacksonXmlProperty(localName = "item")
public BeanInfo[] getBeanOther() {
return beanOther;
}
@JacksonXmlElementWrapper(localName = "beanOther")
public void setBeanOther(BeanInfo[] beanOther) {
this.beanOther = beanOther;
}
}
private static class BeanInfo {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
}
This example give getter definition conflict.
If I change
@JacksonXmlElementWrapper(localName = "beanOther")
@JacksonXmlProperty(localName = "item2")
public BeanInfo[] getBeanOther() {
}
then all work fine and I’ve got
<output><beanInfo><item><name>name</name></item></beanInfo><beanOther><item2><name>name</name></item2></beanOther></output>
but if I try to deserialize it then I’ve got setter definition conflict…
Issue Analytics
- State:
- Created 11 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Conflicting getter definitions for property "time" - Stack Overflow
One way to solve the erase the conflict due to the multiple defined property time preserving your xml format is to create a...
Read more >Developers - @JacksonXmlElementWrapper Conflicting getter ...
@JacksonXmlElementWrapper Conflicting getter/setter definitions for property ... Hi, I'm using latest release 2.0.1 and I've got a problem with ...
Read more >REST API Call revisionInfo Fails For JSON | FishEye - Jira
TotalityFilter-logExceptionDetails - Exception "Conflicting getter definitions for property "ancestor": com.atlassian.fisheye.spi.data.
Read more >How to solve conflicting getter definitions for property in ...
Coding example for the question How to solve conflicting getter definitions for property in jackson without access to source-Java.
Read more >Serialize and Deserialize XML in Java with Jackson
This is a set of markup declarations that define the building blocks of an XML document. ... private String memory; // getters and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@madrob Unlikely this would get resolved any time soon.
This issue has been around for a while, I’m currently upgrading my application from org.codehaus.jackson v1 to com.fasterxml.jackson v2 and hitting this as a regression. Does anybody have a workaround or an ETA for a fix on it?