Hi,

Getting the following error when starting camel:

"This SpringBuilder is not being used with a SpringCamelContext and there is
no applicationContext property configured"

I am starting Camel from Spring by calling the camel Main class and passing
in a reference to my Spring XML file.

Within my code base I have a "SpringRouterBuilder" defined because I want to
take advantage of Spring's transactional features.

When I start camel, I want it to find my SpringRouteBuilder in my sourcebase
(in package com.mycompany.mypackage) and so I put the following XML in my
camel-server.xml:

<camel:camelContext id="camel2"
xmlns="http://activemq.apache.org/camel/schema/spring";>
        <camel:package>com.mycompany.mypackage</camel:package>
</camel:camelContext>

here is my SpringRouteBuilder:

public class EventRouter extends SpringRouteBuilder {

    Policy required 
        = new SpringTransactionPolicy(bean(TransactionTemplate.class,
"PROPAGATION_REQUIRED"));

    @Override
    public void configure() throws Exception {
      
        // Routing of Main Event Queue
        from("jms:queue:incomingEventQueue")
            .policy(required)
            .to("log:incomingEventLogger?level=INFO");

    }
}

I get error stack:

[2009-03-04 10:08:30,187] org.apache.camel.util.MainSupport ERROR  - Failed:
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'camel:beanPostProcessor': Cannot resolve reference to bean
'camel' while setting bean property 'camelContext'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'camel': Invocation of init method failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'com.ee.berbe.mobile.external.EventRouter': Instantiation of bean
failed; nested exception is
org.springframework.beans.BeanInstantiationException: Could not instantiate
bean class [com.ee.berbe.mobile.external.EventRouter]: Constructor threw
exception; nested exception is java.lang.IllegalArgumentException: This
SpringBuilder is not being used with a SpringCamelContext and there is no
applicationContext property configured
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'camel:beanPostProcessor': Cannot resolve reference to bean
'camel' while setting bean property 'camelContext'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'camel': Invocation of init method failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'com.ee.berbe.mobile.external.EventRouter': Instantiation of bean
failed; nested exception is
org.springframework.beans.BeanInstantiationException: Could not instantiate
bean class [com.ee.berbe.mobile.external.EventRouter]: Constructor threw
exception; nested exception is java.lang.IllegalArgumentException: This
SpringBuilder is not being used with a SpringCamelContext and there is no
applicationContext property configured
        at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)
        at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
        at java.security.AccessController.doPrivileged(Native Method)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
        at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
        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.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:881)
        at
org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:606)
        at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:366)
        at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
        at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
        at
org.apache.camel.spring.Main.createDefaultApplicationContext(Main.java:189)
        at org.apache.camel.spring.Main.doStart(Main.java:152)
        at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:47)
        at org.apache.camel.util.MainSupport.run(MainSupport.java:121)
        at org.apache.camel.util.MainSupport.run(MainSupport.java:310)
        at org.apache.camel.spring.Main.main(Main.java:72)
Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'camel': Invocation of init method failed; nested
exception is org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'com.ee.berbe.mobile.external.EventRouter':
Instantiation of bean failed; nested exception is
org.springframework.beans.BeanInstantiationException: Could not instantiate
bean class [com.ee.berbe.mobile.external.EventRouter]: Constructor threw
exception; nested exception is java.lang.IllegalArgumentException: This
SpringBuilder is not being used with a SpringCamelContext and there is no
applicationContext property configured
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1337)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
        at java.security.AccessController.doPrivileged(Native Method)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
        at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
        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.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
        ... 23 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'com.ee.berbe.mobile.external.EventRouter':
Instantiation of bean failed; nested exception is
org.springframework.beans.BeanInstantiationException: Could not instantiate
bean class [com.ee.berbe.mobile.external.EventRouter]: Constructor threw
exception; nested exception is java.lang.IllegalArgumentException: This
SpringBuilder is not being used with a SpringCamelContext and there is no
applicationContext property configured
        at
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:254)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:925)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:835)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
        at java.security.AccessController.doPrivileged(Native Method)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:300)
        at
org.apache.camel.spring.spi.SpringInjector.newInstance(SpringInjector.java:39)
        at
org.apache.camel.spring.RouteBuilderFinder.instantiateBuilder(RouteBuilderFinder.java:121)
        at
org.apache.camel.spring.RouteBuilderFinder.appendBuilders(RouteBuilderFinder.java:85)
        at
org.apache.camel.spring.CamelContextFactoryBean.findRouteBuiders(CamelContextFactoryBean.java:526)
        at
org.apache.camel.spring.CamelContextFactoryBean.afterPropertiesSet(CamelContextFactoryBean.java:254)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334)
        ... 33 more
Caused by: org.springframework.beans.BeanInstantiationException: Could not
instantiate bean class [com.ee.berbe.mobile.external.EventRouter]:
Constructor threw exception; nested exception is
java.lang.IllegalArgumentException: This SpringBuilder is not being used
with a SpringCamelContext and there is no applicationContext property
configured
        at 
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:115)
        at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
        at
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:248)
        ... 47 more
Caused by: java.lang.IllegalArgumentException: This SpringBuilder is not
being used with a SpringCamelContext and there is no applicationContext
property configured
        at
org.apache.camel.spring.SpringRouteBuilder.getApplicationContext(SpringRouteBuilder.java:89)
        at
org.apache.camel.spring.SpringRouteBuilder.bean(SpringRouteBuilder.java:50)
        at com.ee.berbe.mobile.external.EventRouter.<init>(EventRouter.java:17)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at 
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100)
        ... 49 more


I'm using camel 1.5

Looks like I need to be creating a SpringCamelContext from my Spring XML but
have not been able to find anyway to do this. Any ideas?

Thanks
Andrew

-- 
View this message in context: 
http://www.nabble.com/Error%3A-This-SpringBuilder-is-not-being-used-with-a-SpringCamelContext-and-there-is-no-applicationContext-property-configured-tp22326547p22326547.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.

Reply via email to