Announcement Announcement Module
Collapse

JavaConfig forum decommissioned in favor of Core Container

As described at

http://static.springsource.org/sprin...fig/README.TXT

key features of the Spring JavaConfig project have been migrated into the core Spring Framework as of version 3.0.

Please see the Spring 3.0 documentation on @Configuration and @Bean support:

http://static.springsource.org/sprin...tml#beans-java

For any questions related to @Configuration classes and @Bean methods in Spring 3.0, please post in the dedicated 'Core Container' forum at

http://forum.springsource.org/forumdisplay.php?f=26
See more
See less
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized... Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • java.lang.IllegalStateException: ApplicationEventMulticaster not initialized...

    My config class

    Code:
    package my.component.config;
    
    import my.component.client.DataRepositoryImpl;
    import my.component.domain.DataRepository;
    
    import org.springframework.config.java.annotation.Bean;
    import org.springframework.config.java.annotation.Configuration;
    import org.springframework.config.java.annotation.ExternalValue;
    import org.springframework.config.java.annotation.valuesource.PropertiesValueSource;
    
    @Configuration
    @PropertiesValueSource(locations={"classpath:my/component/config/my.properties"})
    public class AppConfig 
    {
    	@ExternalValue("user.name")
    	private String name;
    	
    	@ExternalValue("user.address")
    	private String address;
    	
    	@Bean
    	public DataRepository dataRepository()
    	{
    		return new DataRepositoryImpl(name, address);
    	}
    }
    My main class

    Code:
    package my.component.client;
    
    import my.component.config.AppConfig;
    import my.component.domain.DataRepository;
    
    import org.springframework.config.java.context.JavaConfigApplicationContext;
    
    public class Client 
    {
    	private JavaConfigApplicationContext ctx;
    	
    	public Client() 
    	{
    		ctx = new JavaConfigApplicationContext(AppConfig.class);
    	}
    
    	public void execute()
    	{
    		DataRepository info = ctx.getBean(DataRepository.class);
    		
    		System.out.println(info.retrieveInfo());
    	}
    	
    	public static void main(String[] args) 
    	{
    		Client client = new Client();
    		
    		client.execute();
    	}
    }

    Code:
    Exception in thread "main" java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.config.java.context.JavaConfigApplicationContext@87816d: startup date [Thu Feb 11 18:23:50 SGT 2010]; root of context hierarchy
    	at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:307)
    	at org.springframework.context.support.AbstractApplicationContext.addListener(AbstractApplicationContext.java:827)
    	at org.springframework.context.support.AbstractApplicationContext.addApplicationListener(AbstractApplicationContext.java:367)
    	at org.springframework.config.java.internal.process.InternalConfigurationPostProcessor.wrapInternalBeanFactoryInApplicationContext(InternalConfigurationPostProcessor.java:103)
    	at org.springframework.config.java.internal.process.InternalConfigurationPostProcessor.createInternalBeanFactory(InternalConfigurationPostProcessor.java:91)
    	at org.springframework.config.java.internal.process.InternalConfigurationPostProcessor.postProcessBeanFactory(InternalConfigurationPostProcessor.java:74)
    	at org.springframework.config.java.context.JavaConfigApplicationContext.invokeBeanFactoryPostProcessors(JavaConfigApplicationContext.java:121)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:398)
    	at org.springframework.config.java.context.JavaConfigApplicationContext.<init>(JavaConfigApplicationContext.java:80)
    	at my.component.client.Client.<init>(Client.java:14)
    	at my.component.client.Client.main(Client.java:26)


    What happen here? Can anyone explain this?
    Last edited by AFiQ125zR; Feb 11th, 2010, 04:40 AM.
Working...
X