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

XML config isn't fully supported for web integration tests if Groovy is on the classpath [SPR-12768] #17365

spring-issuemaster opened this issue Feb 28, 2015 · 1 comment


None yet
2 participants
Copy link

commented Feb 28, 2015

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]


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" />


  1. Ensure that it is possible to use all features of XML configuration when loading a WebApplicationContext in the TestContext framework if Groovy is on the classpath.

Affects: 4.1 GA

Reference URL:

Issue Links:

  • #17366 GroovyBeanDefinitionReader does not fully support XML config files

Referenced from: commits 55eb5b6, 2ba1151


This comment has been minimized.

Copy link
Collaborator Author

commented Feb 28, 2015

Sam Brannen commented

Fixed as described in the GitHub comments for commits 2ba1151 (4.2) and 55eb5b6 (4.1.6):

Support XML config fully in web integration tests

Prior to this commit, it was impossible to use all features of XML
configuration (e.g., the <qualifier> tag) in web-based integration
tests (loaded using @WebAppConfiguration, @ContextConfiguration, etc.)
if the Groovy library was on the classpath. The reason is that the
GroovyBeanDefinitionReader used internally by
GenericGroovyXmlWebContextLoader disables XML validation for its
internal XmlBeanDefinitionReader, and this prevents some XML
configuration features from working properly. For example, the default
value for the 'type' attribute (defined in the spring-beans XSD) of the
<qualifier> tag gets ignored, resulting in an exception when the
application context is loaded.

This commit addresses this issue by refactoring the implementation of
loadBeanDefinitions() in GenericGroovyXmlWebContextLoader to use an
XmlBeanDefinitionReader or GroovyBeanDefinitionReader depending on the
file extension of the resource location from which bean definitions
should be loaded. This aligns the functionality of
GenericGroovyXmlWebContextLoader with the existing functionality of

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.