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

JaxbMarshaller scan should skip annotated interfaces [SPR-13221] #17812

Closed
spring-issuemaster opened this issue Jul 11, 2015 · 0 comments
Closed

JaxbMarshaller scan should skip annotated interfaces [SPR-13221] #17812

spring-issuemaster opened this issue Jul 11, 2015 · 0 comments
Assignees
Milestone

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Jul 11, 2015

Kiril Nugmanov opened SPR-13221 and commented

Spring JAXB marshaller (org.springframework.oxm.jaxb.Jaxb2Marshaller) incorrectly scans packages with JAXB annotations.

Problems is when package is being scanned used org.springframework.oxm.jaxb.ClassPathJaxb2TypeScanner which checks if class has following annotations:

  • XmlRootElement
  • XmlType
  • XmlSeeAlso
  • XmlEnum
  • XmlRegistry

So if you generating client from WSDL - webservice interface will have an anotation XmlSeeAlso.

Whis annotatio leads to the error

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'marshaller' defined in class path resource [application.xml]: Invocation of init method failed; nested exception is org.springframework.oxm.UncategorizedMappingException: Unknown JAXB exception; nested exception is com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
org.cynic.test.client.Service is an interface, and JAXB can't handle interfaces.
	this problem is related to the following location:
		at org.cynic.test.client.Service
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
        <property name="packagesToScan" value="org.cynic.test.client"/>
    </bean>
</beans>

The only dirty fix is to downgrade JAXB binding version from 2.1 to 2.0
For more details why this annotation is being generated on interfaces see this post

Solution should be following: org.springframework.oxm.jaxb.ClassPathJaxb2TypeScanner must ignore annotated interfaces (even if there is default implementation for Java 8)

I can create pull request (after discussion).


Affects: 4.1.7

Referenced from: commits 18c4671

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.