You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Willem Jiang (JIRA)" <ji...@apache.org> on 2009/06/11 14:57:35 UTC

[jira] Issue Comment Edited: (CAMEL-1696) Refreshing a bundle with a camel-cxf route gives exception 'BeanFactory not initialized or already closed

    [ https://issues.apache.org/activemq/browse/CAMEL-1696?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=52204#action_52204 ] 

Willem Jiang edited comment on CAMEL-1696 at 6/11/09 5:57 AM:
--------------------------------------------------------------

When call the ConfigurerImpl.addApplicationContext(ctx) to add a new application context, we need to check if the ConfigureImpl's ApplicationContext is closed.
Since if we closed the application context which the ConfigureImpl has and add a new application context to it, we will got the exception of "BeanFactory not initialized or already closed".

I work around this issue by clean up the BusFactory default factory when the application context is closed, but we still need to fix this issue in CXF[1].

[1] https://issues.apache.org/jira/browse/CXF-2279 

      was (Author: njiang):
    When call the ConfigurerImpl.addApplicationContext(ctx) to add a new application context, we need to check if the ConfigureImpl's ApplicationContext is closed.
Since if we closed the application context which the ConfigureImpl has and add a new application context to it, we will got the exception of "BeanFactory not initialized or already closed".

And this is a common use case in OSGi world, such as refresh a OSGi Bundle with a camel-cxf route.

I workaround this issue by clean up the BusFactory default factory when the application context is closed, but we still need to fix this issue in CXF[1].

[1] https://issues.apache.org/jira/browse/CXF-2279 
  
> Refreshing a bundle with a camel-cxf route gives exception 'BeanFactory not initialized or already closed
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-1696
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1696
>             Project: Apache Camel
>          Issue Type: Bug
>    Affects Versions: 1.6.0, 2.0-M1, 1.6.1
>            Reporter: Willem Jiang
>            Assignee: Willem Jiang
>             Fix For: 1.6.2, 2.0.0
>
>
> smx@root:/> osgi/refresh 120
> smx@root:/> Exception in thread "SpringOsgiExtenderThread-16" org.springframework.beans.factory.BeanCreationException: E
> rror creating bean with name 'illustrationGenerationEndpoint': Initialization of bean failed; nested exception is java.l
> ang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the
> ApplicationContext
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCap
> ableBeanFactory.java:480)
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBea
> nFactory.java:409)
> at java.security.AccessController.doPrivileged(Native Method)
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapab
> leBeanFactory.java:380)
> at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
> at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegis
> try.java:222)
> at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
> at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
> at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
> at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListable
> BeanFactory.java:429)
> at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplic
> ationContext.java:728)
> at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDel
> egatedExecutionApplicationContext.java:68)
> at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegated
> ExecutionApplicationContext.java:343)
> at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
> at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(Abstrac
> tDelegatedExecutionApplicationContext.java:308)
> at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$Co
> mpleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:138)
> at java.lang.Thread.run(Thread.java:595)
> Caused by: java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before access
> ing beans via the ApplicationContext
> at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableA
> pplicationContext.java:153)
> at org.springframework.context.support.AbstractApplicationContext.getBeanDefinitionNames(AbstractApplicationCont
> ext.java:929)
> at org.apache.cxf.configuration.spring.ConfigurerImpl.initWildcardDefinitionMap(ConfigurerImpl.java:77)
> at org.apache.cxf.configuration.spring.ConfigurerImpl.addApplicationContext(ConfigurerImpl.java:223)
> at org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor.updateBusReferencesInContext(BusWiringBeanFactory
> PostProcessor.java:118)
> at org.apache.camel.component.cxf.spring.CxfEndpointBeanDefinitionParser$CxfSpringEndpointBean.setApplicationCon
> text(CxfEndpointBeanDefinitionParser.java:115)
> at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(Applicat
> ionContextAwareProcessor.java:70)
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeIni
> tialization(AbstractAutowireCapableBeanFactory.java:350)
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireC
> apableBeanFactory.java:1331)
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCap
> ableBeanFactory.java:473)
> ... 16 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.