有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java组织。springframework。豆。工厂BeanCreationNotAllowedException:创建名为“cxf”的bean时出错:单例bean创建

我正在尝试为我的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>

如果您需要以上任何详细信息,请告诉我

以下是整个堆栈跟踪

 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) 个答案

  1. # 1 楼答案

    这种情况的发生主要是因为以前在服务器上运行应用程序的某些方面。因此,它无法创建bean。因此,据我所知,在我遇到这个问题时,我会选择tomcat选项或任何服务器选项,并将部署时间重置为更长的时间。例如,如果您提供执行此工作所需的时间,tomcat将取消部署应用程序的任何实例并重新启动

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

    我希望这会有所帮助

    凯亚