Skip to content
This repository has been archived by the owner on Jan 22, 2019. It is now read-only.

JaxbAnnotationIntrospector creates an element from an attribute instead of an attribute #27

Closed
jbuhacoff opened this issue Mar 24, 2014 · 4 comments
Milestone

Comments

@jbuhacoff
Copy link

This is a duplicate of issue #6 for jackson version 2.3.2; the comments on that bug report ended with it not being reproducible.

Please see the junit test and classpath being used in my stackoverflow question: http://stackoverflow.com/questions/22433679/how-to-use-jacksons-jaxbannotationintrospector-correctly

Someone answered my stackoverflow question saying that com.fasterxml.jackson.dataformat.xml.jaxb.XmlJaxbAnnotationIntrospector seems to work fine. I confirmed that when I replace JaxbAnnotationIntrospector with XmlJaxbAnnotationIntrospector in my junit test I get the expected output.

Since there is a solution (use XmlJaxbAnnotationIntrospector) maybe the quickest fix is to update the documentation to suggest using XmlJaxbAnnotationIntrospector in cases where the XML output from JaxbAnnotationIntrospector is not in line with the JAXB annotations.

@cowtowncoder
Copy link
Member

Division of labor should be quite straight-forward: JAXB module only recognized JAXB annotations; and other modules recognized annotations they add, so Jackson XML module's introspectors understand annotations defined there. JAXB module (this project) has no dependency to Jackson XML module, and so can not technically handle annotations from it.

The canonical way to use both annotations is to use two (or more) AnnotationIntrospector implementations, and chain them using AnnotationIntrospectorPair.

But XML module does depend on JAXB annotations module for historical reasons, so it is true that XmlJaxbAnnotationIntrospector can be used for convenience: it does support both sets of annotations.

@cowtowncoder
Copy link
Member

Just realized that test case referred did use both sets of annotations, but only to demonstrate the issue. So I will try to see if I can reproduce the issue.

@cowtowncoder
Copy link
Member

Ah. Yes, I can reproduce the problem. Will need to see whether it can be fixed, or if it requires documentation -- I don't know off-hand.

Thank you for helping reproduce this problem!

cowtowncoder added a commit that referenced this issue Mar 25, 2014
cowtowncoder added a commit that referenced this issue Mar 25, 2014
@cowtowncoder cowtowncoder reopened this Mar 25, 2014
@cowtowncoder cowtowncoder added this to the 2.4.0 milestone Mar 25, 2014
@cowtowncoder
Copy link
Member

Ok: I was able to not only reproduce the issue, but actually fix it. Unfortunately needed changes mean this is 2.4-only fix (see FasterXML/jackson-dataformat-xml#111).
Until 2.4, use of XmlJaxbAnnotationIntrospector is needed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants