Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.9
-
Fix Version/s: None
-
Component/s: Spring Components
-
Testcase included:yes
-
Number of attachments :
Description
I have attached a small sample project (using fabric3-samples-spring-restcalc project from Spring samples) that configures Camel context in Spring configuration file (META-INF/camel-context.xml) and creates a simple Camel route with Java DSL.
This is the Spring configuration for Camel:
<bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent"> <property name="location" value="camel.properties" /> </bean> <bean id="helloBean" class="org.fabric3.samples.rs.calculator.HelloBean" /> <bean id="routeBuilder" class="org.fabric3.samples.rs.calculator.CamelRouteBuilder" /> <camel:camelContext id="camel"> <camel:routeBuilder ref="routeBuilder" /> </camel:camelContext>
Even though properties bean should not be mandatory for Camel to work (actually there is no such property file even camel.properties) Fabric3 gives this error if it is missing:
[ERROR main 2012-02-16 09:52:42,047] An error was encountered deploying a contribution org.fabric3.host.domain.DeploymentException: org.fabric3.spi.executor.ExecutionException: org.fabric3.implementation.spring.runtime.component.SpringComponentStartException: Error starting component: fabric3://domain/RESTCalculator at org.fabric3.fabric.domain.LocalDeployer.execute(LocalDeployer.java:116) at org.fabric3.fabric.domain.LocalDeployer.deploy(LocalDeployer.java:92) at org.fabric3.fabric.domain.AbstractDomain.allocateAndDeploy(AbstractDomain.java:601) at org.fabric3.fabric.domain.AbstractDomain.instantiateAndDeploy(AbstractDomain.java:500) at org.fabric3.fabric.domain.AbstractDomain.include(AbstractDomain.java:249) at org.fabric3.contribution.scanner.impl.ContributionDirectoryScanner.onEvent(ContributionDirectoryScanner.java:162) at org.fabric3.fabric.event.EventServiceImpl.publish(EventServiceImpl.java:71) at org.fabric3.fabric.runtime.DefaultCoordinator.start(DefaultCoordinator.java:122) at org.fabric3.runtime.standalone.server.Fabric3Server.start(Fabric3Server.java:187) at org.fabric3.runtime.standalone.server.Fabric3Server.main(Fabric3Server.java:104) Caused by: org.fabric3.spi.executor.ExecutionException: org.fabric3.implementation.spring.runtime.component.SpringComponentStartException: Error starting component: fabric3://domain/RESTCalculator at org.fabric3.fabric.executor.StartComponentCommandExecutor.execute(StartComponentCommandExecutor.java:94) at org.fabric3.fabric.executor.StartComponentCommandExecutor.execute(StartComponentCommandExecutor.java:66) at org.fabric3.fabric.executor.CommandExecutorRegistryImpl.execute(CommandExecutorRegistryImpl.java:76) at org.fabric3.fabric.domain.LocalDeployer.execute(LocalDeployer.java:112) ... 9 common frames omitted Caused by: org.fabric3.implementation.spring.runtime.component.SpringComponentStartException: Error starting component: fabric3://domain/RESTCalculator at org.fabric3.implementation.spring.runtime.component.SpringComponent.start(SpringComponent.java:135) at org.fabric3.fabric.executor.StartComponentCommandExecutor.execute(StartComponentCommandExecutor.java:92) ... 12 common frames omitted Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'camel': Invocation of init method failed; nested exception is org.apache.camel.RuntimeCamelException: java.lang.NullPointerException at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1412) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:281) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:872) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423) at org.fabric3.implementation.spring.runtime.component.SpringComponent.start(SpringComponent.java:132) ... 13 common frames omitted Caused by: org.apache.camel.RuntimeCamelException: java.lang.NullPointerException at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1196) at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookup(PropertyPlaceholderDelegateRegistry.java:64) at org.apache.camel.impl.DefaultCamelContext.getPropertiesComponent(DefaultCamelContext.java:2113) at org.apache.camel.impl.DefaultCamelContext.resolvePropertyPlaceholders(DefaultCamelContext.java:985) at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookup(PropertyPlaceholderDelegateRegistry.java:60) at org.apache.camel.util.CamelContextHelper.lookup(CamelContextHelper.java:106) at org.apache.camel.model.RouteBuilderDefinition.createRouteBuilder(RouteBuilderDefinition.java:64) at org.apache.camel.core.xml.AbstractCamelContextFactoryBean.installRoutes(AbstractCamelContextFactoryBean.java:637) at org.apache.camel.core.xml.AbstractCamelContextFactoryBean.afterPropertiesSet(AbstractCamelContextFactoryBean.java:312) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1469) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409) ... 25 common frames omitted Caused by: java.lang.NullPointerException: null at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:1096) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:1070) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1056) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:274) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.fabric3.implementation.spring.runtime.component.ProxyBeanFactory.getBean(ProxyBeanFactory.java:83) at org.fabric3.implementation.spring.runtime.component.ProxyBeanFactory.getBean(ProxyBeanFactory.java:96) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:266) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1049) at org.apache.camel.spring.spi.ApplicationContextRegistry.lookup(ApplicationContextRegistry.java:43) at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookup(PropertyPlaceholderDelegateRegistry.java:62) ... 34 common frames omitted [INFO main 2012-02-16 09:52:42,067] Fabric3 ready [Mode:VM, Environment: production]
When adding properties for Camel that error goes away. But we get another (even though similar and routing to the same cause I think) error later.
This is the Camel route:
from("timer:hello?delay=1000").beanRef("helloBean", "sayHello").to("stream:out");
It simply just calls helloBean.sayHello() (which returns String "hello") and routes it to System.out.
This works when run in eg. a JUnit test (test is included in attached Maven project) but when trying to deploy it to Fabric3 I get this error:
Exception in thread "main" org.fabric3.runtime.standalone.server.Fabric3ServerException: org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> Bean[ref:helloBean method: sayHello] <<< in route: Route[[From[timer:hello?delay=1000]] -> [Bean[ref:helloBean ... because of java.lang.NullPointerException at org.fabric3.runtime.standalone.server.Fabric3Server.handleStartException(Fabric3Server.java:259) at org.fabric3.runtime.standalone.server.Fabric3Server.start(Fabric3Server.java:208) at org.fabric3.runtime.standalone.server.Fabric3Server.main(Fabric3Server.java:104) Caused by: org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> Bean[ref:helloBean method: sayHello] <<< in route: Route[[From[timer:hello?delay=1000]] -> [Bean[ref:helloBean ... because of java.lang.NullPointerException at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1196) at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:122) at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:240) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:301) at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:888) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:426) at org.fabric3.implementation.spring.runtime.component.SpringComponent.start(SpringComponent.java:132) at org.fabric3.fabric.executor.StartComponentCommandExecutor.execute(StartComponentCommandExecutor.java:92) at org.fabric3.fabric.executor.StartComponentCommandExecutor.execute(StartComponentCommandExecutor.java:66) at org.fabric3.fabric.executor.CommandExecutorRegistryImpl.execute(CommandExecutorRegistryImpl.java:76) at org.fabric3.fabric.domain.LocalDeployer.execute(LocalDeployer.java:112) at org.fabric3.fabric.domain.LocalDeployer.deploy(LocalDeployer.java:92) at org.fabric3.fabric.domain.AbstractDomain.allocateAndDeploy(AbstractDomain.java:601) at org.fabric3.fabric.domain.AbstractDomain.instantiateAndDeploy(AbstractDomain.java:500) at org.fabric3.fabric.domain.AbstractDomain.include(AbstractDomain.java:249) at org.fabric3.contribution.scanner.impl.ContributionDirectoryScanner.onEvent(ContributionDirectoryScanner.java:162) at org.fabric3.fabric.event.EventServiceImpl.publish(EventServiceImpl.java:71) at org.fabric3.fabric.runtime.DefaultCoordinator.start(DefaultCoordinator.java:122) at org.fabric3.runtime.standalone.server.Fabric3Server.start(Fabric3Server.java:187) ... 1 more Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> Bean[ref:helloBean method: sayHello] <<< in route: Route[[From[timer:hello?delay=1000]] -> [Bean[ref:helloBean ... because of java.lang.NullPointerException at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:855) at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:168) at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:704) at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1701) at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1496) at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1391) at org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:181) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60) at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1359) at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:230) at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:120) ... 19 more Caused by: org.apache.camel.RuntimeCamelException: java.lang.NullPointerException at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1196) at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookup(PropertyPlaceholderDelegateRegistry.java:64) at org.apache.camel.component.bean.BeanInfo.createParameterMappingStrategy(BeanInfo.java:133) at org.apache.camel.component.bean.RegistryBean.createParameterMappingStrategy(RegistryBean.java:132) at org.apache.camel.component.bean.RegistryBean.getParameterMappingStrategy(RegistryBean.java:116) at org.apache.camel.component.bean.RegistryBean.createBeanInfo(RegistryBean.java:128) at org.apache.camel.component.bean.RegistryBean.getBeanInfo(RegistryBean.java:97) at org.apache.camel.model.BeanDefinition.createProcessor(BeanDefinition.java:216) at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:436) at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:178) at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:852) ... 29 more Caused by: java.lang.NullPointerException at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:1096) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:1070) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1056) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:274) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.fabric3.implementation.spring.runtime.component.ProxyBeanFactory.getBean(ProxyBeanFactory.java:83) at org.fabric3.implementation.spring.runtime.component.ProxyBeanFactory.getBean(ProxyBeanFactory.java:96) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:266) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1049) at org.apache.camel.spring.spi.ApplicationContextRegistry.lookup(ApplicationContextRegistry.java:43) at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookup(PropertyPlaceholderDelegateRegistry.java:62) ... 38 more