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

Regression in 5.1 RC3: BeanDefinitionOverrideException against mock config [SPR-17287] #21820

Closed
spring-projects-issues opened this issue Sep 18, 2018 · 2 comments
Assignees
Labels
in: core status: invalid

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Sep 18, 2018

David J. M. Karlsen opened SPR-17287 and commented

Using spring boot 2.1.0.M3, which is spring-framework v5.1.0RC3, I get:

 


ava.lang.IllegalStateException: Failed to load ApplicationContext Caused by: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'cachedConnectionFactory' defined in class path resource [com/edb/fs/tac/jfr/srv/ws/infra/mq/MqConfig.class]: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=true; factoryBeanName=mqConfig; factoryMethodName=connectionFactory; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/edb/fs/tac/jfr/srv/ws/infra/mq/MqConfig.class]] for bean 'cachedConnectionFactory': There is already [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=camelCxfTransportTest.MockConfig; factoryMethodName=cachedConnectionFactory; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/edb/fs/tac/jfr/srv/ws/CamelCxfTransportTest$MockConfig.class]] bound.

 

which I do not do with latest GA releases of sb / sf.

 

The mock config is used as an inner config bean in another test:


@Configuration
static class MockConfig {
 @Bean
 public DestinationManager destinationManager() {
 return new DestinationManager();
 }

 @Bean
 public ConfigurationManager configurationManager() {
 return new ConfigurationManager();
 }

 @Bean
 public MockConnectionFactory cachedConnectionFactory( ConfigurationManager configurationManager,
 DestinationManager destinationManager ) {
 return new MockConnectionFactory(destinationManager,configurationManager);
 }

 @Bean
 public JmsTransactionManager jmsTransactionManager(ConnectionFactory connectionFactory) {
 return new JmsTransactionManager(connectionFactory);
 }

 @Bean
 public JmsTemplate jmsTemplate(ConnectionFactory connectionFactory) {
 return new JmsTemplate(connectionFactory);
 }
}

My failing smoke test:


@ExtendWith( SpringExtension.class )
@ActiveProfiles( {
 "eammock",
 "noOpCache",
 "dev"
})
@SpringBootTest( classes = \{ Application.class } )
public class ApplicationBootupSmokeTest
 extends AbstractTest
{

 @Inject
 private ConfigurableWebApplicationContext webApplicationContext;

 @Test
 public void testAbleToCreateWebAppContext() {
 assertThat(webApplicationContext ).isNotNull();
 assertThat(webApplicationContext.isActive() ).isTrue();
 }
}

 

I don't think the other test should pick up the 1st tests inner mock-config?


Affects: 5.1 RC3

Issue Links:

  • #21838 Regression in Spring 5.1
@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 18, 2018

Brian Clozel commented

This is probably due to a change in Spring Boot itself, which now disables by default bean overriding (see #13609). You can try and re-enable it with the configuration property spring.main.allow-bean-definition-overriding=true.

For other questions on that matter, please join the Spring Boot gitter channel or ask questions on StackOverflow. Thanks!

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 18, 2018

David J. M. Karlsen commented

spot on - that was it - thanks a lot!

@spring-projects-issues spring-projects-issues added status: invalid type: regression in: core labels Jan 11, 2019
@spring-projects-issues spring-projects-issues removed the type: regression label Jan 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core status: invalid
Projects
None yet
Development

No branches or pull requests

2 participants