Order of deploying routes to JBoss Fuse matters
Issue
Below steps you should take to reproduce the problem.
- Get clean Fuse 6 container (data folder removed)
- Build and install two attached artifacts
- Open karaf console and execute in the following order (order does matter)
features:addurl mvn:com.example.esb/camel-cxf-test/1-SNAPSHOT/xml/features
features:install camel-cxf-test
features:addurl mvn:com.example.esb/camel-rest-test/1-SNAPSHOT/xml/features
features:install camel-rest-test
features:uninstall camel-cxf-test
features:uninstall camel-rest-test
features:install camel-cxf-test
features:install camel-rest-test
After last command I see following exception:
JBossFuse:karaf@root> Exception in thread "SpringOsgiExtenderThread-8" org.apache.camel.RuntimeCamelException: org.apache.cxf.service.factory.ServiceConstructionException
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1326)
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:120)
at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:283)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:327)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:941)
at org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.
java:132)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException
at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:194)
at org.apache.camel.component.cxf.jaxrs.CxfRsConsumer.<init>(CxfRsConsumer.java:38)
at org.apache.camel.component.cxf.jaxrs.CxfRsEndpoint.createConsumer(CxfRsEndpoint.java:111)
at org.apache.camel.impl.EventDrivenConsumerRoute.addServices(EventDrivenConsumerRoute.java:65)
at org.apache.camel.impl.DefaultRoute.onStartingServices(DefaultRoute.java:80)
at org.apache.camel.impl.RouteService.warmUp(RouteService.java:133)
at org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:2000)
at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:1928)
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:1716)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1597)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1453)
at org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:179)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1421)
at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:228)
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:118)
... 10 more
Caused by: java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:172)
at org.springframework.context.support.AbstractApplicationContext.containsBean(AbstractApplicationContext.java:1121)
at org.apache.cxf.configuration.spring.ConfigurerImpl.configureBean(ConfigurerImpl.java:145)
at org.apache.cxf.configuration.spring.ConfigurerImpl.configureBean(ConfigurerImpl.java:115)
at org.apache.cxf.transport.http.HTTPTransportFactory.configure(HTTPTransportFactory.java:186)
at org.apache.cxf.transport.http.HTTPTransportFactory.configure(HTTPTransportFactory.java:180)
at org.apache.cxf.transport.http.HTTPTransportFactory.getDestination(HTTPTransportFactory.java:289)
at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:93)
at org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:72)
at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:151)
... 25 more
But if we change the order of deployment everything works. Below steps when everything works:
- Get clean Fuse 6 container (data folder removed)
- Build and install two attached artifacts
- Open karaf console and execute in the following order (order does matter)
features:addurl mvn:com.example.esb/camel-rest-test/1-SNAPSHOT/xml/features
features:install camel-rest-test
features:addurl mvn:com.example.esb/camel-cxf-test/1-SNAPSHOT/xml/features
features:install camel-cxf-test
features:uninstall camel-rest-test
features:uninstall camel-cxf-test
features:install camel-rest-test
features:install camel-cxf-test
Environment
JBoss Fuse 6.0
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
