Skip to content

Improve exception message: Default SmartContextLoaders do not support locations and @Configuration classes simultaneously [SPR-12060] #16676

Closed
@spring-projects-issues

Description

@spring-projects-issues

Stephane Mikaty opened SPR-12060 and commented

Overview

I'm still getting the error mentioned in the reference URL, and I have not found any other mention of this edge case. Is this by design or simply not implemented yet?

I attached the files I used as reproduction.

  1. demo.notworking exhibits the issue
  2. demo.working works as expected and so I think Spring core JMS pom.xml #1 could well be supported with a simple code fix.

When running demo.notworking.ConcreteSubTest as JUnit Test, I get the following:

java.lang.IllegalStateException: Neither GenericXmlContextLoader nor AnnotationConfigContextLoader was able to load an ApplicationContext from [MergedContextConfiguration@7e02286 testClass = ConcreteSubTest, locations = '{classpath:/test-config.xml}', classes = '{class demo.notworking.ConcreteSubTest$Config}', contextInitializerClasses = '[]', activeProfiles = '{}', contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]].

When running demo.working.ConcreteSubTest as JUnit Test, I get the following:

org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [demo.StringLabelBean] is defined: expected single matching bean but found 2: demo.StringLabelBean#0,bean

Deliverables

  1. Improve exception message in AbstractDelegatingSmartContextLoader.loadContext() to provide better clarity in scenarios like the one described above.

Affects: 3.2.6, 3.2.10, 4.0.6

Reference URL: http://forum.spring.io/forum/spring-projects/container/125452-contextconfiguration-inheritance-mixing-xml-and-bean-configuration-in-spring-tests

Attachments:

Referenced from: commits 181299c

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions