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 76A7DCDCC for ; Thu, 3 May 2012 11:29:36 +0000 (UTC) Received: (qmail 88973 invoked by uid 500); 3 May 2012 11:29:35 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 88942 invoked by uid 500); 3 May 2012 11:29:35 -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 Received: (qmail 88934 invoked by uid 99); 3 May 2012 11:29:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 May 2012 11:29:35 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [128.130.30.52] (HELO mail.intern.tuwien.ac.at) (128.130.30.52) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 May 2012 11:29:30 +0000 Received: from MBX1.intern.tuwien.ac.at ([169.254.1.5]) by htc2.intern.tuwien.ac.at ([fe80::1cdd:8671:ffae:9525%17]) with mapi id 14.02.0283.003; Thu, 3 May 2012 13:29:02 +0200 From: Ilger Gerda To: "users@camel.apache.org" Subject: RE: Mistakes in endpoints prevent start of camel context Thread-Topic: Mistakes in endpoints prevent start of camel context Thread-Index: Ac0odWy2921lIGlJSDiQoZAfxSIY2gAefZ6AAAE9ZYAACbUYMA== Date: Thu, 3 May 2012 11:29:02 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US, de-AT Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [128.131.167.8] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org Thanks Claus.=20 So basically the best way would be to just validate the Strings I use to cr= eate the endpoints before using them, is that right? It still crashes with the same exception when I set autoStartup false: [DEBUG] - - Warming up route id: route1 having = autoStartup=3Dfalse [main] [o.a.c.s.SpringCamelContext] But since I'd like to keep autoStartup anyway, there's no point investigati= ng. Re Christian - catching the exception: Is that what you're suggesting: static class BadRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { try { from("ftp://illegalUrl:::123").to("direct:b"); } catch(Exception e) { // we don't end up here =09 } } } I believe that I'd have to catch the exception in the loop in DefaultCamelC= ontext.doWarmUpRoutes - meaning I'd have to subclass SpringCamelContext, ha= d to override doWarmUpRoutes, and then I'd have to clean up all references = to the route ... I don't think I want to do that ... or is there a clean, = non-error-prone, easy way I'm missing? Validating the strings before passing them to camel's "from" method sounds = a lot safer. Thanks, Gerda Here's the stack trace (just in case you're curious - thanks everyone for y= our help!): java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.TestContext.getApplicationContext(Test= Context.java:157) at org.springframework.test.context.support.DependencyInjectionTestExecuti= onListener.injectDependencies(DependencyInjectionTestExecutionListener.java= :109) at org.springframework.test.context.support.DependencyInjectionTestExecuti= onListener.prepareTestInstance(DependencyInjectionTestExecutionListener.jav= a:75) at org.springframework.test.context.TestContextManager.prepareTestInstance= (TestContextManager.java:321) at org.springframework.test.context.testng.AbstractTestNGSpringContextTest= s.springTestContextPrepareTestInstance(AbstractTestNGSpringContextTests.jav= a:133) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.ja= va:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesso= rImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocatio= nHelper.java:80) at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:551) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138) at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMetho= dWorker.java:175) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107) at org.testng.TestRunner.privateRun(TestRunner.java:768) at org.testng.TestRunner.run(TestRunner.java:617) at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at org.testng.SuiteRunner.run(SuiteRunner.java:240) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185) at org.testng.TestNG.runSuitesLocally(TestNG.java:1110) at org.testng.TestNG.run(TestNG.java:1022) at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:109) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:202) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:173) Caused by: org.springframework.beans.factory.BeanCreationException: Error c= reating bean with name 'camelContext' defined in class at.erpel.messaginghu= b.unit.routes.BadRouteDefinitionTest$ContextConfig: Invocation of init meth= od failed; nested exception is java.lang.IllegalArgumentException: host mus= t be specified and not empty at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFa= ctory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFa= ctory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFa= ctory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObje= ct(AbstractBeanFactory.java:294) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.= getSingleton(DefaultSingletonBeanRegistry.java:225) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean= (AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(A= bstractBeanFactory.java:193) at org.springframework.beans.factory.support.DefaultListableBeanFactory.pr= eInstantiateSingletons(DefaultListableBeanFactory.java:585) at org.springframework.context.support.AbstractApplicationContext.finishBe= anFactoryInitialization(AbstractApplicationContext.java:913) at org.springframework.context.support.AbstractApplicationContext.refresh(= AbstractApplicationContext.java:464) at org.apache.camel.spring.javaconfig.test.JavaConfigContextLoader.loadCon= text(JavaConfigContextLoader.java:125) at org.springframework.test.context.TestContext.loadApplicationContext(Tes= tContext.java:130) at org.springframework.test.context.TestContext.getApplicationContext(Test= Context.java:148) ... 28 more Caused by: java.lang.IllegalArgumentException: host must be specified and n= ot empty at org.apache.camel.util.ObjectHelper.notEmpty(ObjectHelper.java:319) at org.apache.camel.component.file.remote.RemoteFileEndpoint.afterProperti= esSet(RemoteFileEndpoint.java:108) at org.apache.camel.component.file.remote.RemoteFileEndpoint.createConsume= r(RemoteFileEndpoint.java:75) at org.apache.camel.component.file.remote.RemoteFileEndpoint.createConsume= r(RemoteFileEndpoint.java:31) at org.apache.camel.impl.EventDrivenConsumerRoute.addServices(EventDrivenC= onsumerRoute.java:65) at org.apache.camel.impl.DefaultRoute.onStartingServices(DefaultRoute.java= :80) at org.apache.camel.impl.RouteService.warmUp(RouteService.java:133) at org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelCo= ntext.java:1925) at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(Defa= ultCamelContext.java:1853) at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(Default= CamelContext.java:1646) at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelCont= ext.java:1534) at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.j= ava:1421) at org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.j= ava:179) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60) at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.jav= a:1389) at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContex= t.java:228) at org.apache.camel.spring.SpringCamelContext.afterPropertiesSet(SpringCam= elContext.java:104) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFa= ctory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFa= ctory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452) ... 40 more -----Original Message----- From: Christian M=FCller [mailto:christian.mueller@gmail.com]=20 Sent: Thursday, May 03, 2012 10:17 AM To: users@camel.apache.org Subject: Re: Mistakes in endpoints prevent start of camel context But if you create the route at runtime via the Java DSL, you can catch the = Exception and handle it in the way you want, e.g. ignore it. Best, Christian On Thu, May 3, 2012 at 9:41 AM, Claus Ibsen wrote: > On Wed, May 2, 2012 at 5:21 PM, Ilger Gerda > wrote: > > Hi all, > > > > We have a number of ftp consumer routes that we start based on URLs=20 > > read > from our database. > > If there's a typo in the URL (e.g. "ftp://localhost::1023"), the=20 > > whole > camelContext won't start. > > We're using SpringCamelContext. > > > > These routes are not essential, we still want our application to=20 > > start & > camel provide all the other routes we defined. > > Is there a way to ignore routes that throw exceptions upon > creation/camel context start (have camel behave as if we never added them= )? > > > > You can configure the routes with autoStartup=3Dfalse. > > But there is currently no option to say, well I dont care if a route=20 > cannot startup. > > > > Thanks, > > Gerda > > > > -- > Claus Ibsen > ----------------- > CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com=20 > FuseSource > Email: cibsen@fusesource.com > Web: http://fusesource.com > Twitter: davsclaus, fusenews > Blog: http://davsclaus.blogspot.com/ > Author of Camel in Action: http://www.manning.com/ibsen/ >