Hi Try with a default no-arg constructor in your route class so it has no other dependency and see if it can be found then. If so then its maybe a problem with those 2 args you specify as dependency.
On Wed, Jul 1, 2015 at 4:53 PM, alexis.jacquemart <[email protected]> wrote: > I'm working with Apache Camel to create route between dynamic endpoints. I > was working with a Main which works but now I need to deploy the application > on an Apache Tomcat server. The problem his that my camel-context doesn't > found my route builder. Here is my applicationContext : > > /<bean id="myRoute" class="com.ittb.boa.jis.extractor.MyRouteBuilder"> > <constructor-arg name="src" ref="logsFileConnector" /> > <constructor-arg name="dest" ref="elasticSearchConnector" /> > </bean> > > <camelContext id="myCamel" > xmlns="http://camel.apache.org/schema/spring"> > <routeBuilder ref="myRoute" /> > </camelContext>/ > > And I'm getting the following error : > > /[ localhost-startStop-1] ContextLoader > ERROR Context initialization failed > org.apache.camel.RuntimeCamelException: org.apache.camel.CamelException: > Cannot find any routes with this RouteBuilder reference: > RouteBuilderRef[myRoute] > at > org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1619)[camel-core-2.15.2.jar:2.15.2] > at > org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:328)[camel-spring-2.15.2.jar:2.15.2] > at > org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:151)[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE] > at > org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128)[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE] > at > org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:331)[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE] > at > org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:773)[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE] > at > org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:483)[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE] > at > org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)[spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE] > at > org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)[spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE] > at > org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)[spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE] > at > org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4728)[catalina.jar:8.0.21] > at > org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5166)[catalina.jar:8.0.21] > at > org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)[catalina.jar:8.0.21] > at > org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)[catalina.jar:8.0.21] > at > org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)[catalina.jar:8.0.21] > at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_45] > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_45] > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_45] > at java.lang.Thread.run(Thread.java:745)[:1.8.0_45] > juil. 01, 2015 2:55:15 PM org.apache.catalina.core.StandardContext > listenerStart > GRAVE: Exception lors de l'envoi de l'évènement contexte initialisé > (context initialized) à l'instance de classe d'écoute (listener) > org.springframework.web.context.ContextLoaderListener > org.apache.camel.RuntimeCamelException: org.apache.camel.CamelException: > Cannot find any routes with this RouteBuilder reference: > RouteBuilderRef[myRoute] > at > org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1619) > at > org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:328) > at > org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:151) > at > org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128) > at > org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:331) > at > org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:773) > at > org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:483) > at > org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) > at > org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) > at > org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) > at > org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4728) > at > org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5166) > at > org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) > at > org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409) > at > org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399) > at java.util.concurrent.FutureTask.run(FutureTask.java:266) > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) > at java.lang.Thread.run(Thread.java:745) > Caused by: org.apache.camel.CamelException: Cannot find any routes with > this RouteBuilder reference: RouteBuilderRef[myRoute] > at > org.apache.camel.core.xml.AbstractCamelContextFactoryBean.installRoutes(AbstractCamelContextFactoryBean.java:832) > at > org.apache.camel.core.xml.AbstractCamelContextFactoryBean.setupRoutes(AbstractCamelContextFactoryBean.java:352) > at > org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:326) > ... 17 more/ > > I've tried to debug it with an EndPoint on configure() in MyRouteBuilder and > the error appears before the breakpoint.. > > Here is the method configure() which is quite heavy : > > /public class MyRouteBuilder extends RouteBuilder { > private ConnectorEndPoint src; > private ConnectorEndPoint dest; > > int i = 0; > private String CRON_EXPRESSION_QUARTZ = > CRONGenerator.generateCRONExpression("0/1", "9-17", "?", "*", "MON-FRI"); > > private MyProcessor processor = new MyProcessor(); > RestConsumerFactory consumerFactory = new RestConsumerFactory() { > public Consumer createConsumer(CamelContext camelContext, > Processor > processor, String verb, String basePath, String uriTemplate, String > consumes, String produces, Map<String, Object> parameters) throws Exception > { > return null; > } > }; > > public MyRouteBuilder(ConnectorEndPoint src, ConnectorEndPoint dest) { > this.src = src; > this.dest = dest; > } > > public void configure() { > if (src instanceof ConnectorSQL){ > from("quartz2://foo?cron="+ CRON_EXPRESSION_QUARTZ) > .to(src.getRouteFrom()) > .bean(processor, "conversionNumericAndDate") > .bean(processor, "standardisation") > .to(dest.getRouteTo()); > } else if (src instanceof ConnectorMongoDB){ > from("quartz2://foo?cron="+ CRON_EXPRESSION_QUARTZ) > .to(src.getRouteFrom()) > .bean(processor, "convertDBObjectToString") > //.bean(processor, "conversionNumericAndDate") > .to(dest.getRouteTo()); > } else if (src instanceof ConnectorREST){ > from("quartz2://foo?cron="+ > CRON_EXPRESSION_QUARTZ).to(src.getRouteFrom()) > //.bean(processor, "conversionNumericAndDate") > //.bean(processor, "standardisation") > .to(dest.getRouteTo()); > } else if (src instanceof ConnectorXMLFile){ > XmlJsonDataFormat xmlJsonFormat = new > XmlJsonDataFormat(); > xmlJsonFormat.setEncoding("UTF-8"); > xmlJsonFormat.setForceTopLevelObject(true); > xmlJsonFormat.setTrimSpaces(true); > xmlJsonFormat.setSkipNamespaces(true); > xmlJsonFormat.setRemoveNamespacePrefixes(true); > from("file:xml?scheduler=quartz2&scheduler.cron="+ > CRON_EXPRESSION_QUARTZ) > .marshal(xmlJsonFormat) > .to(dest.getRouteTo()); > } else if (src instanceof ConnectorLogsFile){ > ArrayListAggregationStrategy aggregationStrategy = new > ArrayListAggregationStrategy(); > from(src.getRouteFrom()) > .bean(processor, "lineFilter(${body}, " + > src.getFieldToFilter() +", " + > src.getFirstValue() +", " + src.getSecondValue() + ")") > .split(body().tokenize("\n")) > .filter().method(MyFilter.class, "isValidError") > .bean(processor, "processLogsApplicationSource") > .filter().method(MyFilter.class, "dateFilter(${body}, > " + > src.getFieldToFilter() +", " + src.getFirstValue() +", " + > src.getSecondValue() + ")") > .aggregate(body(), > aggregationStrategy).completionInterval(1000) > .to(dest.getRouteTo()); > } else { > System.err.println("Erreur : Type de endpoint en > entrée inconnu"); > System.exit(1); > } > } > / > So, it's like the camel context doesn't launch configure() method so the > RouteBuilder is not created and not found by the context.. My web.xml is : > > / <context-param> > <param-name>contextConfigLocation</param-name> > <param-value>classpath:applicationContext.xml</param-value> > </context-param> > <listener> > > <listener-class>org.apache.camel.component.servletlistener.SimpleCamelServletContextListener</listener-class> > </listener> > <listener> > > <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> > </listener>/ > > I've already create a StackoverFlow question at : here > <http://stackoverflow.com/questions/31161111/apache-camel-routebuilder-in-spring-doesnt-launch-configure> > Thanks for your help ! > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Apache-Camel-RouteBuilder-in-Spring-doesn-t-launch-configure-tp5768754.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen ----------------- Red Hat, Inc. Email: [email protected] Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/
