-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Description
Sam Brannen opened SPR-12768 and commented
Status Quo
As discussed in the "spring-test, groovy library and qualifier tag incompatibility" thread on Stack Overflow, it is currently impossible to configure an integration test using @WebAppConfiguration and XML config that uses the <qualifier> tag if Groovy is on the classpath. Any attempt to do so will result in a stack trace similar to the following.
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unexpected failure during bean definition parsing
Offending resource: class path resource [spring/app-config.xml]
Bean 'service'; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Tag 'qualifier' must have a 'type' attribute
Offending resource: class path resource [spring/app-config.xml]
Analysis
The reason that the aforementioned BeanDefinitionParsingException is thrown is that GenericGroovyXmlWebContextLoader internally uses a GroovyBeanDefinitionReader for loading bean definitions from XML configuration files, and GroovyBeanDefinitionReader disables XML validation for its internal XmlBeanDefinitionReader.
The absence of XML validation apparently causes the default value of the type attribute (from the spring-beans XSD) in the <qualifier> tag to be ignored.
Temporary Work-around
It is possible to circumvent this bug by explicitly setting the type attribute in the <qualifier> tag to the intended default value which is "org.springframework.beans.factory.annotation.Qualifier" - for example, as follows.
<bean id="foo" class="java.lang.String" c:_="bar">
<qualifier value="foo" type="org.springframework.beans.factory.annotation.Qualifier" />
</bean>Deliverables
- Ensure that it is possible to use all features of XML configuration when loading a
WebApplicationContextin the TestContext framework if Groovy is on the classpath.
Affects: 4.1 GA
Reference URL: http://stackoverflow.com/questions/28212993/spring-test-groovy-library-and-qualifier-tag-incompatibility
Issue Links:
- GroovyBeanDefinitionReader does not fully support XML config files [SPR-12769] #17366 GroovyBeanDefinitionReader does not fully support XML config files