2

When trying to run my executable jar that Spring boot has created for me I keep getting this exception.

If I do not declare base packages for my component scan the embedded server comes up without any problems.But I need to declare base packages for my current project.

Component scan declaration:

@ComponentScan({"com.teradata.notification","com.teradata.dal"})

Stacktrace:

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.boot.autoconfigure.MessageSourceAutoConfiguration' is defined

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.boot.autoconfigure.MessageSourceAutoConfiguration' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:638)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1159)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:959)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.requiresEagerInitForType(DefaultListableBeanFactory.java:451)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:380)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:353)
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:141)
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:103)
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:77)
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:43)
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:92)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:174)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:136)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:324)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:107)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:609)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:616)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:877)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:866)
at com.teradata.notification.Application.main(Application.java:16)
Muhi Masoud
  • 207
  • 1
  • 3
  • 7
  • Maybe you could post the code somewhere? Or at least a full stack trace? – Dave Syer Mar 20 '14 at 07:11
  • @DaveSyer please take a look at my org question is has the code included. http://stackoverflow.com/questions/22442822/spring-boot-and-componentscan-between-two-jars – Muhi Masoud Mar 20 '14 at 14:59
  • The stacktrace is incomplete. Is this one a duplicate of that question? – Dave Syer Mar 20 '14 at 15:50
  • @DaveSyer full stack trace added. No not a dup just a side effect of adding a base package to the '@ComponentScan'. – Muhi Masoud Mar 21 '14 at 14:30
  • 1
    My guess is something in the neo4j configuration is causing early instantiation of some factory beans (maybe it's trying to use a `MessageSource`?). If you could put some code on github that would probably make it easier to diagnose. – Dave Syer Mar 21 '14 at 17:11
  • @DaveSyer Ok I will add the 2 projects to github this weekend. Thank you for the help. – Muhi Masoud Mar 21 '14 at 17:30
  • 1
    Judging from the link you posted your `Application` class doesn't have a `@Configuration` which, if I'm not mistaken, basically renders the `@EnableAutoConfiguration` useless as the given `@Import` is ignored. So add `@Configuration`. – M. Deinum Sep 18 '14 at 13:11

0 Answers0