Announcement Announcement Module
No announcement yet.
@EnableSpringConfigured gives BeanFactory has not been set on BeanConfigurerSupport Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • @EnableSpringConfigured gives BeanFactory has not been set on BeanConfigurerSupport

    I'm facing an issue with AspectJ Dependency Injection when creating objects with the 'new' keyword.

    I have 3 Configuration classes: the main, the web and for doing some data creation in the development environment.

    The AppConfig contains the @EnableSpringConfigured annotation to enable dependency injection when creating new domain objects. This class looks like:

    @ComponentScan(basePackages = { "my.project" }, excludeFilters = { @Filter(type = FilterType.ANNOTATION, value = Configuration.class) })
    @PropertySource({ "classpath:/META-INF/", "classpath:/META-INF/config-${my.project.runtime.environment}.properties" })
    public class AppConfig {
    The DevelopmentBootStrapConfig looks like:

    public class DevelopmentBootStrapConfig {
    	public BootStrap bootStrap() {
    		return new BootStrap();
    	private class BootStrap {
    		public void init() {
    			// create data by instantiating domain classes with 'new'
    Note that this one does not have the @EnableSpringConfigured as I *assume* once (in AppConfig) should be enough.

    I'm loading the configuration classes with the following definition in web.xml:

    When running this code on local (!) Google App Engine the AOP stuff works perfectly as expected.
    But on the production Google Infrastructure I always notices inconsistent behavior as the AOP aspects did not seem to work always between deployments. Note that that time I was using dailly development snapshots of Spring 3.1 so I did not give it much attention then as it worked quit often the other day. Also note that I was changing my own JAva config setup because of new features in different 3.1 RC's

    Now after the 3.1 GA locally everything works still fine, but on Google App Engine infrastructure I'm not able to get it working anymore. Spring works fine on it, only the AOP seems to be broken with @EnableSpringConfigured.

    Today I dived into it again and I noticed this DEBUG message on the Google App Engine infrastructure:

    DEBUG [org.springframework.beans.factory.wiring.BeanConfigurerSupport] 
    BeanFactory has not been set on BeanConfigurerSupport: Make sure this configurer runs in a Spring container. Unable to configure bean of type [my.project.domain.User]. Proceeding without injection.
    Another thing I found out is that when I move the BootStrap @Bean definition and inner class from DevelopmentBootStrapConfig to AppConfig it works on Google App Engine infrastructure.

    Is there something I'm doing wrong?

    Could it maybe the case that on the Configuration classes are processed in different order?
    E.g. DevelopmentBootStrapConfig before AppConfig which means @EnableSpringConfigured was not yet invoked maybe?

    I don't know how this internally works...

  • #2
    Hi Marcel,

    This is probably worth a JIRA issue. Please try to explain the simplest possible way to reproduce this on GAE. A simple project that works locally but fails when deployed there would be a big help in getting this looked at.

    In the meantime, it sounds like you have a decent workaround, but nevertheless probably something that should be fixed...


    • #3
      Hi Chris,

      I created JIRA and attached a simple project (Maven) I just verified locally and on Google App Engine infrastructure minutes ago. It runs locally but gives above error on Google App Engine infrastructure.