Spring Framework
  1. Spring Framework
  2. SPR-9019

@EnableSpringConfigured gives BeanFactory has not been set on BeanConfigurerSupport

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Contributions Welcome
    • Component/s: Core, Core:AOP
    • Labels:
      None

      Description

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

      I have 3 Configuration classes: the main AppConfig.java, the web MvcConfig.java and BootStrapConfig.java for doing some data creation.

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

      @Configuration
      @ComponentScan(basePackages = "com.appspot.springaop")
      @EnableSpringConfigured
      public class AppConfig {
      	..
      }
      

      The BootStrapConfig looks like:

      @Configuration
      public class BootStrapConfig {
      	
      	@Bean
      	public BootStrap bootStrap() {
      		return new BootStrap();
      	}
      
      	private class BootStrap {
      
      		@PostConstruct
      		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:

      	<context-param>
      		<param-name>contextClass</param-name>
      		<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
      	</context-param>
      
      	<context-param>
      		<param-name>contextConfigLocation</param-name>
      		<param-value>com.appspot.springaop.config</param-value>
      	</context-param>
      

      When running this code on local Google App Engine the AOP stuff works perfectly as expected.
      But on the production Google Infrastructure I always noticed 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.

      Note that I also noticed this DEBUG message on the Google App Engine infrastructure:

      [s~spring-aop/3.356043308451020324].<stdout>: 10:39:43,186 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 [com.appspot.springaop.domain.Book]. Proceeding without injection.
      

      Another thing I found out is that when I move the BootStrap @Bean definition and inner class from BootStrapConfig 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...

      For reference I'm als posting the full stack trace I received on Google App Engine infrastructure:

      I 2012-01-12 11:39:38.123
      javax.servlet.ServletContext log: Set web app root system property: 'webapp.root' = [/base/data/home/apps/s~spring-aop/3.356043308451020324]
      
      I 2012-01-12 11:39:38.126
      javax.servlet.ServletContext log: Initializing log4j from [classpath:META-INF/log4j.properties]
      
      I 2012-01-12 11:39:38.891
      javax.servlet.ServletContext log: Initializing Spring root WebApplicationContext
      
      I 2012-01-12 11:39:42.454
      [s~spring-aop/3.356043308451020324].<stdout>: 10:39:42,454 INFO  [com.appspot.springaop.config.AppConfig] Initializing configuration AppConfig...
      
      I 2012-01-12 11:39:43.186
      [s~spring-aop/3.356043308451020324].<stdout>: 10:39:43,186 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 [com.appspot.springaop.domain.Book]. Proceeding without injection.
      
      I 2012-01-12 11:39:43.193
      [s~spring-aop/3.356043308451020324].<stdout>: 10:39:43,190 ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bootStrap': Invocation of init method failed; nested exception is java.lang.IllegalStateException: DatastoreService has not been injected
      	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:135)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1448)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
      	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
      	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
      	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
      	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
      	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:384)
      	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
      	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
      	at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
      	at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
      	at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
      	at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
      	at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
      	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
      	at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:202)
      	at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:171)
      	at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:123)
      	at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:422)
      	at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:449)
      	at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:455)
      	at com.google.tracing.TraceContext.runInContext(TraceContext.java:695)
      	at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:333)
      	at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:325)
      	at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:453)
      	at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
      	at java.lang.Thread.run(Thread.java:679)
      Caused by: java.lang.IllegalStateException: DatastoreService has not been injected
      	at com.appspot.springaop.domain.Book.datastoreService(Book.java:53)
      	at com.appspot.springaop.domain.Book.findByTitle(Book.java:79)
      	at com.appspot.springaop.config.BootStrapConfig$BootStrap.findOrCreateBook(BootStrapConfig.java:35)
      	at com.appspot.springaop.config.BootStrapConfig$BootStrap.init(BootStrapConfig.java:30)
      	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:43)
      	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:346)
      	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:299)
      	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:132)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1448)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
      	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
      	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
      	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
      	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
      	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:384)
      	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
      	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
      	at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
      	at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
      	at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
      	at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
      	at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
      	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
      	at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:449)
      	at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:455)
      	at com.google.tracing.TraceContext.runInContext(TraceContext.java:695)
      	at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:333)
      	at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:325)
      	at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:453)
      	... 1 more
      
      W 2012-01-12 11:39:43.194
      Failed startup of context com.google.apphosting.utils.jetty.RuntimeAppEngineWebAppContext@974600{/,/base/data/home/apps/s~spring-aop/3.356043308451020324}
      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bootStrap': Invocation of init method failed; nested exception is java.lang.IllegalStateException: DatastoreService has not been injected
      	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:135)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1448)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
      	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
      	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
      	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
      	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
      	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:384)
      	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
      	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
      	at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
      	at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
      	at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
      	at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
      	at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
      	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
      	at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:202)
      	at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:171)
      	at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:123)
      	at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:422)
      	at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:449)
      	at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:455)
      	at com.google.tracing.TraceContext.runInContext(TraceContext.java:695)
      	at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:333)
      	at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:325)
      	at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:453)
      	at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
      	at java.lang.Thread.run(Thread.java:679)
      Caused by: java.lang.IllegalStateException: DatastoreService has not been injected
      	at com.appspot.springaop.domain.Book.datastoreService(Book.java:53)
      	at com.appspot.springaop.domain.Book.findByTitle(Book.java:79)
      	at com.appspot.springaop.config.BootStrapConfig$BootStrap.findOrCreateBook(BootStrapConfig.java:35)
      	at com.appspot.springaop.config.BootStrapConfig$BootStrap.init(BootStrapConfig.java:30)
      	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:43)
      	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:346)
      	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:299)
      	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:132)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1448)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
      	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
      	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
      	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
      	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
      	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:384)
      	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
      	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
      	at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
      	at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
      	at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
      	at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
      	at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
      	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
      	at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:449)
      	at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:455)
      	at com.google.tracing.TraceContext.runInContext(TraceContext.java:695)
      	at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:333)
      	at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:325)
      	at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:453)
      	... 1 more
      	
      W 2012-01-12 11:39:43.196
      Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bootStrap': Invocation of init method failed; nested exception is java.lang.IllegalStateException: DatastoreService has not been injected:
      java.lang.IllegalStateException: DatastoreService has not been injected
      	at com.appspot.springaop.domain.Book.datastoreService(Book.java:53)
      	at com.appspot.springaop.domain.Book.findByTitle(Book.java:79)
      	at com.appspot.springaop.config.BootStrapConfig$BootStrap.findOrCreateBook(BootStrapConfig.java:35)
      	at com.appspot.springaop.config.BootStrapConfig$BootStrap.init(BootStrapConfig.java:30)
      	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:43)
      	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:346)
      	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:299)
      	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:132)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1448)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
      	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
      	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
      	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
      	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
      	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:384)
      	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
      	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
      	at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
      	at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
      	at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
      	at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
      	at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
      	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
      	at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:449)
      	at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:455)
      	at com.google.tracing.TraceContext.runInContext(TraceContext.java:695)
      	at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:333)
      	at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:325)
      	at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:453)
      	at java.lang.Thread.run(Thread.java:679)
      	
      C 2012-01-12 11:39:43.200
      Uncaught exception from servlet
      javax.servlet.UnavailableException: Initialization failed.
      	at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:211)
      	at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:171)
      	at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:123)
      	at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:422)
      	at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:449)
      	at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:455)
      	at com.google.tracing.TraceContext.runInContext(TraceContext.java:695)
      	at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:333)
      	at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:325)
      	at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:453)
      	at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
      	at java.lang.Thread.run(Thread.java:679)
      

      As requested in the dicussion forum I have also uploaded a simple example project (Maven) that runs locally but gives above error on Google App Engine infrastructure.

        Activity

        Hide
        Sateesh Valluru added a comment -

        I had the same problem and debugging through found that internalBeanConfigurerAspect was being created only upon finishing the initialization of the context.
        I ended up doing the following to solve the issue, but I am not sure it's a good idea:
        1. Add @DependsOn("org.springframework.context.config.internalBeanConfigurerAspect")
        2. in XML create a bean extending InstantiationAwareBeanPostProcessorAdapter
        and adding <bean class="com.ciphercloud.context.ForceConfigurable" depends-on="org.springframework.context.config.internalBeanConfigurerAspect" /> to the xml.

        Essentially trying to make Spring context pre instantiate the internalBeanConfigurerAspect.

        Show
        Sateesh Valluru added a comment - I had the same problem and debugging through found that internalBeanConfigurerAspect was being created only upon finishing the initialization of the context. I ended up doing the following to solve the issue, but I am not sure it's a good idea: 1. Add @DependsOn("org.springframework.context.config.internalBeanConfigurerAspect") 2. in XML create a bean extending InstantiationAwareBeanPostProcessorAdapter and adding <bean class="com.ciphercloud.context.ForceConfigurable" depends-on="org.springframework.context.config.internalBeanConfigurerAspect" /> to the xml. Essentially trying to make Spring context pre instantiate the internalBeanConfigurerAspect.
        Hide
        Gerrit Hübbers added a comment -

        @Sateesh, can you clarify your step 2? What is <bean class="com.ciphercloud.context.ForceConfigurable" ..." />?

        Show
        Gerrit Hübbers added a comment - @Sateesh, can you clarify your step 2? What is <bean class="com.ciphercloud.context.ForceConfigurable" ..." />?
        Hide
        Sateesh Valluru added a comment -

        It's just a bean that I added, with the following content:
        @DependsOn caused the internalBeanConfigurerAspect to be pre instantiated.

        @DependsOn("org.springframework.context.config.internalBeanConfigurerAspect")
        public class ForceConfigurable extends InstantiationAwareBeanPostProcessorAdapter

        { @Autowired ApplicationContext context; }
        Show
        Sateesh Valluru added a comment - It's just a bean that I added, with the following content: @DependsOn caused the internalBeanConfigurerAspect to be pre instantiated. @DependsOn("org.springframework.context.config.internalBeanConfigurerAspect") public class ForceConfigurable extends InstantiationAwareBeanPostProcessorAdapter { @Autowired ApplicationContext context; }
        Hide
        Chris Beams added a comment -

        Given that this issue is comparatively unlikely (occurs only for GAE-based apps using @SpringConfigured, and even then probably only in certain situations), and has not received many votes, I'm putting this in the "Contributions Welcome" bucket for now. If anyone familiar with GAE is feeling ambitious and can provide us with an analysis of what precisely is happening differently in that environment, we might be able to take steps to fix it. Naturally, a pull request would be even better.

        Show
        Chris Beams added a comment - Given that this issue is comparatively unlikely (occurs only for GAE-based apps using @SpringConfigured , and even then probably only in certain situations), and has not received many votes, I'm putting this in the "Contributions Welcome" bucket for now. If anyone familiar with GAE is feeling ambitious and can provide us with an analysis of what precisely is happening differently in that environment, we might be able to take steps to fix it. Naturally, a pull request would be even better.

          People

          • Assignee:
            Unassigned
            Reporter:
            Marcel Overdijk
            Last updater:
            Chris Beams
          • Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Days since last comment:
              1 year, 8 weeks, 1 day ago