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.

@JacksonXmlElementWrapper Conflicting getter/setter definitions for property

See original GitHub issue

Hi, 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:open
  • Created 11 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
cowtowncodercommented, Oct 10, 2017

@madrob Unlikely this would get resolved any time soon.

1reaction
madrobcommented, Oct 9, 2017

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?

Read more comments on GitHub >

github_iconTop 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 >

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