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

RepositoryBeanNameGenerator fails to resolve bean names for custom implementations detected via Spring's component index [DATACMNS-1115] #1558

Closed
spring-projects-issues opened this issue Jul 18, 2017 · 1 comment
Assignees
Milestone

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Jul 18, 2017

Juergen Zimmermann opened DATACMNS-1115 and commented

After upgrading to Spring Boot 2.0.0.M2 and Spring Data Kay.M4 I cannot start my microservices any more which are accessing MongoDB. A testcase is appended to produce the stacktrace below.
First I thought it is a Spring Boot issue spring-projects/spring-boot#9780
Stacktrace:

C:\Users\ziju0001\IdeaProjects\testcase>gradle

> Task :bootRun

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::             (v2.0.0.M2)

2017-07-18 20:03:31.441  INFO 8572 --- [           main] de.hska.test.Main                        : Starting Main on iwi-w-ziju01-d with PID 8572 (C:\Users\ziju0001\IdeaProjects\testcase\build\classes\java\main started by ziju0001 in C:\Users\ziju0001\IdeaProjects\testcase)
2017-07-18 20:03:31.441  INFO 8572 --- [           main] de.hska.test.Main                        : No active profile set, falling back to default profiles: default
2017-07-18 20:03:31.551  INFO 8572 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@402e37bc: startup date [Tue Jul 18 20:03:31 CEST 2017]; root of context hierarchy
2017-07-18 20:03:33.051 ERROR 8572 --- [           main] o.s.boot.SpringApplication               : Application startup failed

java.lang.NullPointerException: null
        at org.springframework.data.repository.config.RepositoryBeanNameGenerator.getRepositoryInterfaceFromFactory(RepositoryBeanNameGenerator.java:81) ~[spring-data-commons-2.0.0.M4.jar:na]
        at org.springframework.data.repository.config.RepositoryBeanNameGenerator.getRepositoryInterfaceFrom(RepositoryBeanNameGenerator.java:75) ~[spring-data-commons-2.0.0.M4.jar:na]
        at org.springframework.data.repository.config.RepositoryBeanNameGenerator.generateBeanName(RepositoryBeanNameGenerator.java:52) ~[spring-data-commons-2.0.0.M4.jar:na]
        at org.springframework.data.repository.config.RepositoryConfigurationSourceSupport.generateBeanName(RepositoryConfigurationSourceSupport.java:92) ~[spring-data-commons-2.0.0.M4.jar:na]
        at org.springframework.data.repository.config.DefaultRepositoryConfiguration.getImplementationBeanName(DefaultRepositoryConfiguration.java:109) ~[spring-data-commons-2.0.0.M4.jar:na]
        at org.springframework.data.repository.config.RepositoryBeanDefinitionBuilder.registerCustomImplementation(RepositoryBeanDefinitionBuilder.java:150) ~[spring-data-commons-2.0.0.M4.jar:na]
        at org.springframework.data.repository.config.RepositoryBeanDefinitionBuilder.build(RepositoryBeanDefinitionBuilder.java:120) ~[spring-data-commons-2.0.0.M4.jar:na]
        at org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn(RepositoryConfigurationDelegate.java:120) ~[spring-data-commons-2.0.0.M4.jar:na]
        at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport.registerBeanDefinitions(AbstractRepositoryConfigurationSourceSupport.java:60) ~[spring-boot-autoconfigure-2.0.0.M2.jar:2.0.0.M2]
        at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.lambda$loadBeanDefinitionsFromRegistrars$0(ConfigurationClassBeanDefinitionReader.java:355) ~[spring-context-5.0.0.RC2.jar:5.0.0.RC2]
        at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) ~[na:1.8.0_131]
        at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:354) ~[spring-context-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:144) ~[spring-context-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117) ~[spring-context-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:320) ~[spring-context-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:229) ~[spring-context-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:271) ~[spring-context-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94) ~[spring-context-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686) ~[spring-context-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524) ~[spring-context-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:122) ~[spring-boot-2.0.0.M2.jar:2.0.0.M2]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[spring-boot-2.0.0.M2.jar:2.0.0.M2]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386) ~[spring-boot-2.0.0.M2.jar:2.0.0.M2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) ~[spring-boot-2.0.0.M2.jar:2.0.0.M2]
        at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:136) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
        at de.hska.test.Main.main(Main.java:13) [main/:na]

2017-07-18 20:03:33.051  INFO 8572 --- [           main] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@402e37bc: startup date [Tue Jul 18 20:03:31 CEST 2017]; root of context hierarchy
2017-07-18 20:03:33.066  WARN 8572 --- [           main] ConfigServletWebServerApplicationContext : Exception thrown from LifecycleProcessor on context close

java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@402e37bc: startup date [Tue Jul 18 20:03:31 CEST 2017]; root of context hierarchy
        at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:426) [spring-context-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:996) [spring-context-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:955) [spring-context-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:808) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
        at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:136) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
        at de.hska.test.Main.main(Main.java:13) [main/:na]

2017-07-18 20:03:33.066 ERROR 8572 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Destroy method on bean with name 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory' threw an exception

java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@402e37bc: startup date [Tue Jul 18 20:03:31 CEST 2017]; root of context hierarchy
        at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:413) [spring-context-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.context.support.ApplicationListenerDetector.postProcessBeforeDestruction(ApplicationListenerDetector.java:97) ~[spring-context-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:236) ~[spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:581) [spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:557) [spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:944) [spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:526) [spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:951) [spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1027) [spring-context-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1003) [spring-context-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:955) [spring-context-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:808) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
        at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:136) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
        at de.hska.test.Main.main(Main.java:13) [main/:na]

Affects: 2.0 M4 (Kay)

Attachments:

Backported to: 1.13.5 (Ingalls SR5), 1.12.12 (Hopper SR12)

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jul 19, 2017

Oliver Drotbohm commented

Just for reference: this problem doesn't occur with a simple upgrade. The culprit here is the addition of the indexer. I've patched RepositoryBeanNameGenerator for all maintained versions so that they stay compatible with Spring 5 using the newly introduced component indexing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.