org.springframework.beans.factory.BeanCreationNotAllowedException:创建名为'cxf'的bean时出错:Singleton bean创建

时间:2014-07-03 05:37:07

标签: java maven dependency-injection cxf spring-aop

我正在尝试创建一个用于记录我的helix服务的方面。 一段时间以来我一直坚持这个错误。如果你们能帮助我,我将不胜感激。 以下是我的XML:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:jaxrs="http://cxf.apache.org/jaxrs"

xmlns:aop="http://www.springframework.org/schema/aop" 
xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd

    http://cxf.apache.org/jaxrs
    http://cxf.apache.org/schemas/jaxrs.xsd
    http://www.springframework.org/schema/aop 
    http://www.springframework.org/schema/aop/spring-aop-4.0.xsd 
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-4.0.xsd
    http://www.springframework.org/schema/jee
    http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
    http://www.springframework.org/schema/task
    http://www.springframework.org/schema/task/spring-task-4.0.xsd">

<import resource="classpath:framework.xml" />
<import resource="classpath*:config/jackson.spring.xml" />



<bean id="wordEchoBean" class="com.example.mypackage.JavaFileforTestAspect"/>


<bean id="testAspect" class="com.example.mypackage.TestAspect" />

<aop:config>
    <aop:aspect id="aspects" ref="testAspect">
        <aop:pointcut id="pointCutBefore"
            expression="execution(* com.example.mypackage.*(..))" />
        <aop:before method="doBefore" pointcut-ref="pointCutBefore" />
    </aop:aspect>
</aop:config>

<jaxrs:server id="wordEchoService" depends-on="modulesInitialization">
    <jaxrs:serviceBeans>
        <ref bean="wordEchoBean" />
    </jaxrs:serviceBeans>

如果您需要更多详细信息,请与我们联系。

以下是整个Stack Trace。

 ERROR [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-4) Destroy method on bean with name '(inner bean)' threw an exception: 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!)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:212)
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.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1093)
at org.apache.cxf.bus.spring.Jsr250BeanPostProcessor.getResourceManager(Jsr250BeanPostProcessor.java:91)
at org.apache.cxf.bus.spring.Jsr250BeanPostProcessor.postProcessBeforeDestruction(Jsr250BeanPostProcessor.java:153)
at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:193)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:498)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:474)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:442)
at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1066)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:472)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850)
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:89)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_45]
at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45]

1 个答案:

答案 0 :(得分:-1)

这主要是因为你之前在服务器上运行应用程序。由于这个原因,它无法创建bean。所以,据我所知,在我的情况下,当我遇到这个问题时,我会转到tomcat选项或任何服务器选项,并将部署时间重置为更长的时间。例如,tomcat将取消部署应用程序的任何实例,如果您提供完成此工作所需的时间,则重新启动。

我的建议是,当您运行所需的应用程序时,请确保取消部署先前的运行并停止服务器以使其自动启动。

我希望这会有所帮助

科亚