Java.lang.IllegalState Exception LifecylceProcessor and ApplicationEventMulticaster do not initialize when using Spring Boot

I created the spring shell class as follows:

package package.for; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.ComponentScan; @ComponentScan @EnableAutoConfiguration public class AppBooter { public static void main(String args[]){ SpringApplication.run("path/to/context.xml", args); System.out.println("============ done"); do{ }while(true); } } 

context.xml contains a bean pointing to the main class as follows:

 <bean id="starter" class="package.for.AppBooter" /> 

as well as a few other beans that I need.

Regarding dependencies, I have the following:

  <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot</artifactId> <version>1.1.7.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>1.1.7.RELEASE</version> </dependency> <dependency> <groupId>axis</groupId> <artifactId>axis</artifactId> <version>1.4</version> <scope>provided</scope> <exclusions> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> <exclusion> <groupId>axis</groupId> <artifactId>axis-wsdl4j</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId> wsdl4j</groupId> <artifactId>wsdl4j</artifactId> <version>1.6.2</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> <version>1.7.7</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>javax.servlet.jsp-api</artifactId> <version>2.3.1</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>4.1.1.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>4.1.1.RELEASE</version> </dependency> <dependency> <groupId>opensymphony</groupId> <artifactId>sitemesh</artifactId> <version>2.5</version> </dependency> 

However, when I start, I get the following exceptions:

 Exception in thread "main" 2014-10-07 16:12:54.267 INFO 4616 --- [ Thread-1] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot .context.embedded.AnnotationConfigEmbeddedWebApplicationContext@ 6c4cbf96: startup date [Tue Oct 07 16:12:50 CEST 2014]; root of context hierarchy java.lang.NoSuchMethodError: org.springframework.data.repository.config.RepositoryConfigurationDelegate.<init>(Lorg/springframework/data/repository/config/RepositoryConfigurationSource;Lorg/springframework/core/io/ResourceLoader;Lorg/springframework/core/env/Environment;)V at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport.registerBeanDefinitions(AbstractRepositoryConfigurationSourceSupport.java:58) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:319) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:139) 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:94) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:608) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:463) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:109) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691) at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) at org.springframework.boot.SpringApplication.run(SpringApplication.java:952) at org.springframework.boot.SpringApplication.run(SpringApplication.java:941) at package.for.AppBooter.main(AppBooter.java:12) 2014-10-07 16:12:54.303 WARN 4616 --- [ Thread-1] ationConfigEmbeddedWebApplicationContext : Exception thrown from ApplicationListener handling ContextClosedEvent java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot .context.embedded.AnnotationConfigEmbeddedWebApplicationContext@ 6c4cbf96: startup date [Tue Oct 07 16:12:50 CEST 2014]; root of context hierarchy at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:345) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:332) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:879) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.doClose(EmbeddedWebApplicationContext.java:141) at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:808) 2014-10-07 16:12:54.304 WARN 4616 --- [ Thread-1] ationConfigEmbeddedWebApplicationContext : 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 .context.embedded.AnnotationConfigEmbeddedWebApplicationContext@ 6c4cbf96: startup date [Tue Oct 07 16:12:50 CEST 2014]; root of context hierarchy at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:358) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:887) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.doClose(EmbeddedWebApplicationContext.java:141) at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:808) 

As for how I pack the jar, here is a snippet of the plugin:

  <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <mainClass>package.for.AppBooter</mainClass> </configuration> <version>1.1.5.RELEASE</version> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions </plugin> 
+3
source share
4 answers

This was resolved by updating the spring -web and spring -webmvc dependencies to 4.0.7.RELEASE

+4
source

I ran into this error and I already had 4.3.2.RELEASE for spring -web and spring -web-mvc.

He resolved, this was due to the definition of spring-data-releasetrain. Removing this solution to the problem.

+2
source

I think the main cause of the problem is NoSuchMethodError :

 java.lang.NoSuchMethodError: org.springframework.data.repository.config.RepositoryConfigurationDelegate.<init>(Lorg/springframework/data/repository/config/RepositoryConfigurationSource;Lorg/springframework/core/io/ResourceLoader;Lorg/springframework/core/env/Environment;)V at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport.registerBeanDefinitions(AbstractRepositoryConfigurationSourceSupport.java:58) 

You did not provide any information about your Spring Data dependencies, but it looks like you are trying to use a version of one of the Spring Data projects that are incompatible with the Spring version of the Download you are using. Spring Boot provides dependency management for entire Spring data feeds, so your best option is to simply remove the version from any Spring data dependencies in your folder and let Spring manage the load dependencies to control the version.

+1
source

Had the same problem and not related to dependencies.

I had the following code:

 @Configuration public class ConfigurationClass { private final MyProperties MY_PROPERTIES; ConfigurationClass(MyProperties myProperties) { this.MY_PROPERTIES = myProperties } @Bean @LoadBalanced public RestTemplate testRestTemplate(RestTemplateBuilder builder) { return builder.setConnectTimeout(MY_PROPERTIES.getTimeout()).build(); } } 

Changing it to the following made it work:

 @Configuration public class ConfigurationClass { @Bean @LoadBalanced public RestTemplate testRestTemplate(RestTemplateBuilder builder, MyProperties myProperties) { return builder.setConnectTimeout(myProperties.getTimeout()).build(); } } 

I am not sure why this caused the problem. You may not be able to use constructor injection if you want to use it inside beans. Hope someone can answer in the comments

0
source

Source: https://habr.com/ru/post/1210568/


All Articles