Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassPathJaxb2TypeScanner which scans packagesToScan for Jaxb2Marshaller does not scan for @XmlRegistry annotation [SPR-10714] #15342

Closed
spring-projects-issues opened this issue Apr 23, 2013 · 4 comments
Assignees
Labels
in: data type: bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Apr 23, 2013

Sebastiaan van Erk opened SPR-10714 and commented

The ClassPathJaxb2TypeScanner class is a helper class for Jaxb2Marshaller that scans given packages for classes marked with JAXB2 annotations. However, it does not scan for the @XmlRegistry annotation, which is used on ObjectFactory classes.

In some cases, the ObjectFactory classes contain crucial annotations for JAXB such as the following:

@XmlElementDecl(namespace = "http://www.example.com/schemas/mymodule", 
    name = "myElement", substitutionHeadNamespace = "http://www.example.com/schemas/core", 
    substitutionHeadName = "myBaseElement")

Without have scanned these annotations, JAXB will not recognize "myElement" as a valid substitution for "myBaseElement" and unmarshalling will fail.

I have attached a very simple maven project with two test cases which illustrates the issue (pure JAXB).

The resolution of the issue is simple (I have also tested this in the project where we ran into the problem). All that is necessary is to add XmlRegistry to the list of scanned annotations in ClassPathJaxb2TypeScanner, i.e.:

private final TypeFilter[] jaxb2TypeFilters =
          new TypeFilter[]{new AnnotationTypeFilter(XmlRootElement.class, false),
                        new AnnotationTypeFilter(XmlType.class, false), new AnnotationTypeFilter(XmlSeeAlso.class, false),
                        new AnnotationTypeFilter(XmlEnum.class, false), new AnnotationTypeFilter(XmlRegistry.class, false)};

Attachments:

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jul 2, 2013

Arjen Poutsma commented

Moved from SWS to SPR.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jul 24, 2013

Phil Webb commented

#324

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jul 25, 2013

Juergen Hoeller commented

Looks entirely reasonable - Phil, please roll this into 3.2.4 right away...

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jul 29, 2013

Phil Webb commented

Thanks for the pull request! This has been merged to master and also for the upcoming 3.2.4 release.

@spring-projects-issues spring-projects-issues added type: bug in: data labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.2.4 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data type: bug
Projects
None yet
Development

No branches or pull requests

2 participants