Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B25A8189C5 for ; Wed, 1 Jul 2015 15:02:09 +0000 (UTC) Received: (qmail 87766 invoked by uid 500); 1 Jul 2015 15:02:09 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 87725 invoked by uid 500); 1 Jul 2015 15:02:09 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Delivered-To: moderator for users@camel.apache.org Received: (qmail 60786 invoked by uid 99); 1 Jul 2015 14:54:01 -0000 X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.286 X-Spam-Level: ** X-Spam-Status: No, score=2.286 tagged_above=-999 required=6.31 tests=[SPF_SOFTFAIL=0.972, URIBL_BLOCKED=0.001, URI_HEX=1.313] autolearn=disabled Date: Wed, 1 Jul 2015 07:53:20 -0700 (MST) From: "alexis.jacquemart" To: users@camel.apache.org Message-ID: <1435762400000-5768754.post@n5.nabble.com> Subject: Apache Camel RouteBuilder in Spring doesn't launch configure() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 applicatio= n on an Apache Tomcat server. The problem his that my camel-context doesn't found my route builder. Here is my applicationContext :=20 / =09 =09=09 =09 =09=09 =09/ And I'm getting the following error :=20 /[ localhost-startStop-1] ContextLoader =20 ERROR Context initialization failed org.apache.camel.RuntimeCamelException: org.apache.camel.CamelException= : Cannot find any routes with this RouteBuilder reference: RouteBuilderRef[myRoute] =09at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.j= ava:1619)[camel-core-2.15.2.jar:2.15.2] =09at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelCon= textFactoryBean.java:328)[camel-spring-2.15.2.jar:2.15.2] =09at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeL= istener(SimpleApplicationEventMulticaster.java:151)[spring-context-4.1.6.RE= LEASE.jar:4.1.6.RELEASE] =09at org.springframework.context.event.SimpleApplicationEventMulticaster.multica= stEvent(SimpleApplicationEventMulticaster.java:128)[spring-context-4.1.6.RE= LEASE.jar:4.1.6.RELEASE] =09at org.springframework.context.support.AbstractApplicationContext.publishEvent= (AbstractApplicationContext.java:331)[spring-context-4.1.6.RELEASE.jar:4.1.= 6.RELEASE] =09at org.springframework.context.support.AbstractApplicationContext.finishRefres= h(AbstractApplicationContext.java:773)[spring-context-4.1.6.RELEASE.jar:4.1= .6.RELEASE] =09at org.springframework.context.support.AbstractApplicationContext.refresh(Abst= ractApplicationContext.java:483)[spring-context-4.1.6.RELEASE.jar:4.1.6.REL= EASE] =09at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplica= tionContext(ContextLoader.java:403)[spring-web-4.1.6.RELEASE.jar:4.1.6.RELE= ASE] =09at org.springframework.web.context.ContextLoader.initWebApplicationContext(Con= textLoader.java:306)[spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE] =09at org.springframework.web.context.ContextLoaderListener.contextInitialized(Co= ntextLoaderListener.java:106)[spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE] =09at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java= :4728)[catalina.jar:8.0.21] =09at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java= :5166)[catalina.jar:8.0.21] =09at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)[catali= na.jar:8.0.21] =09at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1= 409)[catalina.jar:8.0.21] =09at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1= 399)[catalina.jar:8.0.21] =09at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_4= 5] =09at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1= 142)[:1.8.0_45] =09at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:= 617)[:1.8.0_45] =09at 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'=C3=A9v=C3=A8nement contexte init= ialis=C3=A9 (context initialized) =C3=A0 l'instance de classe d'=C3=A9coute (listener) org.springframework.web.context.ContextLoaderListener org.apache.camel.RuntimeCamelException: org.apache.camel.CamelException= : Cannot find any routes with this RouteBuilder reference: RouteBuilderRef[myRoute] =09at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.j= ava:1619) =09at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelCon= textFactoryBean.java:328) =09at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeL= istener(SimpleApplicationEventMulticaster.java:151) =09at org.springframework.context.event.SimpleApplicationEventMulticaster.multica= stEvent(SimpleApplicationEventMulticaster.java:128) =09at org.springframework.context.support.AbstractApplicationContext.publishEvent= (AbstractApplicationContext.java:331) =09at org.springframework.context.support.AbstractApplicationContext.finishRefres= h(AbstractApplicationContext.java:773) =09at org.springframework.context.support.AbstractApplicationContext.refresh(Abst= ractApplicationContext.java:483) =09at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplica= tionContext(ContextLoader.java:403) =09at org.springframework.web.context.ContextLoader.initWebApplicationContext(Con= textLoader.java:306) =09at org.springframework.web.context.ContextLoaderListener.contextInitialized(Co= ntextLoaderListener.java:106) =09at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java= :4728) =09at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java= :5166) =09at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:1= 50) =09at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1= 409) =09at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1= 399) =09at java.util.concurrent.FutureTask.run(FutureTask.java:266) =09at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1= 142) =09at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:= 617) =09at java.lang.Thread.run(Thread.java:745) Caused by: org.apache.camel.CamelException: Cannot find any routes with this RouteBuilder reference: RouteBuilderRef[myRoute] =09at org.apache.camel.core.xml.AbstractCamelContextFactoryBean.installRoutes(Abs= tractCamelContextFactoryBean.java:832) =09at org.apache.camel.core.xml.AbstractCamelContextFactoryBean.setupRoutes(Abstr= actCamelContextFactoryBean.java:352) =09at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelCon= textFactoryBean.java:326) =09... 17 more/ I've tried to debug it with an EndPoint on configure() in MyRouteBuilder an= d the error appears before the breakpoint..=20 Here is the method configure() which is quite heavy :=20 /public class MyRouteBuilder extends RouteBuilder { =09private ConnectorEndPoint src; =09private ConnectorEndPoint dest; =09 =09int i =3D 0; =09private String CRON_EXPRESSION_QUARTZ =3D CRONGenerator.generateCRONExpression("0/1", "9-17", "?", "*", "MON-FRI"); =09private MyProcessor processor =3D new MyProcessor(); =09RestConsumerFactory consumerFactory =3D new RestConsumerFactory() { =09=09public Consumer createConsumer(CamelContext camelContext, Processor processor, String verb, String basePath, String uriTemplate, String consumes, String produces, Map parameters) throws Exception { =09=09=09return null; =09=09} =09}; =09 =09public MyRouteBuilder(ConnectorEndPoint src, ConnectorEndPoint dest) { =09=09this.src =3D src; =09=09this.dest =3D dest; =09} =09public void configure() { =09=09if (src instanceof ConnectorSQL){ =09=09=09from("quartz2://foo?cron=3D"+ CRON_EXPRESSION_QUARTZ) =09=09=09.to(src.getRouteFrom()) =09=09=09.bean(processor, "conversionNumericAndDate") =09=09=09.bean(processor, "standardisation") =09=09=09.to(dest.getRouteTo()); =09=09} else if (src instanceof ConnectorMongoDB){ =09=09=09from("quartz2://foo?cron=3D"+ CRON_EXPRESSION_QUARTZ) =09=09=09.to(src.getRouteFrom()) =09=09=09.bean(processor, "convertDBObjectToString") =09=09=09//.bean(processor, "conversionNumericAndDate") =09=09=09.to(dest.getRouteTo()); =09=09} else if (src instanceof ConnectorREST){ =09=09=09from("quartz2://foo?cron=3D"+ CRON_EXPRESSION_QUARTZ).to(src.getRouteFrom()) =09=09=09//.bean(processor, "conversionNumericAndDate") =09=09=09//.bean(processor, "standardisation") =09=09=09.to(dest.getRouteTo()); =09=09} else if (src instanceof ConnectorXMLFile){ =09=09=09XmlJsonDataFormat xmlJsonFormat =3D new XmlJsonDataFormat(); =09=09=09xmlJsonFormat.setEncoding("UTF-8"); =09=09=09xmlJsonFormat.setForceTopLevelObject(true); =09=09=09xmlJsonFormat.setTrimSpaces(true); =09=09=09xmlJsonFormat.setSkipNamespaces(true); =09=09=09xmlJsonFormat.setRemoveNamespacePrefixes(true);=09=09=09 =09=09=09from("file:xml?scheduler=3Dquartz2&scheduler.cron=3D"+ CRON_EXPRESSION_QUARTZ) =09=09=09.marshal(xmlJsonFormat) =09=09=09.to(dest.getRouteTo()); =09=09} else if (src instanceof ConnectorLogsFile){ =09=09=09ArrayListAggregationStrategy aggregationStrategy =3D new ArrayListAggregationStrategy(); =09=09=09from(src.getRouteFrom()) =09=09=09.bean(processor, "lineFilter(${body}, " + src.getFieldToFilter() += ", " + src.getFirstValue() +", " + src.getSecondValue() + ")") =09=09=09.split(body().tokenize("\n")) =09=09=09.filter().method(MyFilter.class, "isValidError") =09=09=09.bean(processor, "processLogsApplicationSource") =09=09=09.filter().method(MyFilter.class, "dateFilter(${body}, " + src.getFieldToFilter() +", " + src.getFirstValue() +", " + src.getSecondValue() + ")") =09=09=09.aggregate(body(), aggregationStrategy).completionInterval(1000) =09=09=09.to(dest.getRouteTo()); =09=09} else { =09=09=09System.err.println("Erreur : Type de endpoint en entr=C3=A9e incon= nu"); =09=09=09System.exit(1); =09=09} =09} / 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 : / =09=09contextConfigLocation =09=09classpath:applicationContext.xml =09 =09 =09 org.apache.camel.component.servletlistener.SimpleCamelServl= etContextListener =09 =09 =09 org.springframework.web.context.ContextLoaderListener =09/ I've already create a StackoverFlow question at : here =20 Thanks for your help ! -- View this message in context: http://camel.465427.n5.nabble.com/Apache-Came= l-RouteBuilder-in-Spring-doesn-t-launch-configure-tp5768754.html Sent from the Camel - Users mailing list archive at Nabble.com.