Skip to content

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

@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions