Hi, I try to create an activemq broker using spring and use it from camel spring context. My code is very similar to the example available in the camel-jms test directory (camel-jms/src/test/resources/org/apache/camel/component/jms/spring.xml).
The following route works well <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> <camelContext xmlns="http://camel.apache.org/schema/spring"> <endpoint id="Timer" uri="timer:messages?period=1h"/> <endpoint id="Direct" uri="direct:messages"/> <endpoint id="Split" uri="bean:messages?method=split"/> <endpoint id="GenerateMessages" uri="bean:messages?method=generate"/> <endpoint id="JmsQueueProducer" uri="jmsProducer:queue:test1"/> <endpoint id="JmsQueueConsumer" uri="jmsConsumer:queue:test1?concurrentConsumers=10"/> <endpoint id="Log" uri="log:org.apache.camel.example?level=WARN"/> <route id="ProduceMessages" trace="false"> <from ref="Timer"/> <to ref="GenerateMessages"/> </route> <route id="SplitandProduceMessagesOnActiveMq" trace="false"> <from ref="Direct"/> <to ref="Split"/> <to uri="JmsQueueProducer"/> </route> <route id="ConsumeMessages" trace="false"> <from ref="JmsQueueConsumer"/> <to ref="Log"/> </route> </camelContext> but get the an error when broker bean definition is used in the camel-context.xml file <!-- Create an embedded broker --> <bean id="broker" class="org.apache.activemq.xbean.BrokerFactoryBean"> <property name="config" value="classpath:META-INF/activemq.xml" /> <property name="start" value="true" /> </bean> <!-- Connection for the client --> <bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory" depends-on="broker"> <property name="brokerURL" value="vm://localhost:61616" /> </bean> ERROR Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'broker' defined in file [C:\chm\dvlpt\java\apache\camel\tests\camel-ite st-activemq-highvolume\target\classes\META-INF\spring\camel-context.xml]: Invocation of init method failed; nested exception is org.apache.camel.RuntimeCamelException: or g.apache.camel.FailedToCreateRouteException: Failed to create route SplitandProduceMessagesOnActiveMq at: >>> To[JmsQueueProducer] <<< in route: Route[[From[ref:Direct]] -> [To[ref:Split], To[JmsQueueProdu... because of Failed to resolve endpoint: JmsQueueProducer due to: org.springframework.beans.factory.BeanCreationException: Error crea ting bean with name 'JmsQueueProducer': FactoryBean threw exception on object creation; nested exception is org.apache.camel.ResolveEndpointFailedException: Failed to res olve endpoint: jmsProducer://queue:test1 due to: No component found with scheme: jmsProducer 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.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) 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:219) at org.apache.camel.spring.Main.doStart(Main.java:173) at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:65) at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52) at org.apache.camel.impl.MainSupport.run(MainSupport.java:114) at org.apache.camel.impl.MainSupport.run(MainSupport.java:291) at org.apache.camel.spring.Main.main(Main.java:97) Any idea is welcome ? Regards, Charles Moulliard Senior Enterprise Architect (J2EE, .NET, SOA) Apache Camel - Karaf - ServiceMix Committer ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Blog : http://cmoulliard.blogspot.com | Twitter : http://twitter.com/cmoulliard Linkedin : http://www.linkedin.com/in/charlesmoulliard | Skype: cmoulliard
