Context Initialization Failure -- BeanCreationNotAllowedException
The Spring Context of my application is failing to initialize. Can anyone help me understand why it is failing and how to fix it?
Below are the warning & error messages I'm getting:
[WARN] Invocation of destroy method 'shutdown' failed on bean with name 'cxf'
org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'entityManagerFactory': Singleton bean creation not allowed while the singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
org.springframework.web.context.ContextLoader [ERROR] Context initialization failed
<bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl" destroy-method="shutdown"/>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="${persi开发者_如何学JAVAstence.unit}"/>
<property name="dataSource" ref="pooledDs"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect"/>
<property name="showSql" value="false"/>
<property name="generateDdl" value="false"/>
</bean>
</property>
</bean>
The CXF website doesn't include the destroy-method
call in its example configurations, so it seems like this is a misconfiguration. See this page for details: http://cxf.apache.org/docs/interceptors.html.
I also found a bug tracker for this issue: https://issues.apache.org/jira/browse/CXF-2164. It appears that the destroy method was not implicitly being called in earlier versions of CXF, but that has been fixed in v2.2.11.
So, my suggestion would be to get up to at least that version and just have <bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl" />
in your config.
In my case I had same problem with version 2.5.0, but that was my fault.
I had wrong bean in context.
In detail: I had Spring MVC Controller (named OrderController) annotated with @Controller
without defined name (annotation driven). On the other CXF requires xml configuration AFAIK, so I named bean using java configuration (using @Bean
) as orderController
and somehow when cxf was initialized Spring used this wrong MVC controller and it failed on error listed above.
org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'cxf': Singleton bean creation not allowed while the singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
精彩评论