Thank you Claus, I'll try that.

Yes, the endpoints are dynamically created - based on data entered manually. 

-----Original Message-----
From: Claus Ibsen [mailto:claus.ib...@gmail.com] 
Sent: Thursday, May 03, 2012 2:14 PM
To: users@camel.apache.org
Subject: Re: Mistakes in endpoints prevent start of camel context

Hi

Yeah you can validate the endpoints with

CamelContext.getEndpoint(uri);

Why would you have invalid endpoints in the first place. Do you dynamic compute 
the endpoints before starting Camel?


On Thu, May 3, 2012 at 1:29 PM, Ilger Gerda <il...@big.tuwien.ac.at> wrote:
> Thanks Claus.
> So basically the best way would be to just validate the Strings I use to 
> create 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=false [main] [o.a.c.s.SpringCamelContext] But since I'd 
> like to keep autoStartup anyway, there's no point investigating.
>
>
> 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
>                        }
>                }
>        }
>
> I believe that I'd have to catch the exception in the loop in 
> DefaultCamelContext.doWarmUpRoutes - meaning I'd have to subclass 
> SpringCamelContext, had 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 
> your help!):
> java.lang.IllegalStateException: Failed to load ApplicationContext
>        at 
> org.springframework.test.context.TestContext.getApplicationContext(Tes
> tContext.java:157)
>        at 
> org.springframework.test.context.support.DependencyInjectionTestExecut
> ionListener.injectDependencies(DependencyInjectionTestExecutionListene
> r.java:109)
>        at 
> org.springframework.test.context.support.DependencyInjectionTestExecut
> ionListener.prepareTestInstance(DependencyInjectionTestExecutionListen
> er.java:75)
>        at 
> org.springframework.test.context.TestContextManager.prepareTestInstanc
> e(TestContextManager.java:321)
>        at 
> org.springframework.test.context.testng.AbstractTestNGSpringContextTes
> ts.springTestContextPrepareTestInstance(AbstractTestNGSpringContextTes
> ts.java:133)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
> ava:39)
>        at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> orImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:597)
>        at 
> org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocati
> onHelper.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(TestMeth
> odWorker.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 creating bean with name 'camelContext' defined in class 
> at.erpel.messaginghub.unit.routes.BadRouteDefinitionTest$ContextConfig
> : Invocation of init method failed; nested exception is 
> java.lang.IllegalArgumentException: host must be specified and not 
> empty
>        at 
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanF
> actory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
>        at 
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanF
> actory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
>        at 
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanF
> actory.createBean(AbstractAutowireCapableBeanFactory.java:456)
>        at 
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObj
> ect(AbstractBeanFactory.java:294)
>        at 
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry
> .getSingleton(DefaultSingletonBeanRegistry.java:225)
>        at 
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBea
> n(AbstractBeanFactory.java:291)
>        at 
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(
> AbstractBeanFactory.java:193)
>        at 
> org.springframework.beans.factory.support.DefaultListableBeanFactory.p
> reInstantiateSingletons(DefaultListableBeanFactory.java:585)
>        at 
> org.springframework.context.support.AbstractApplicationContext.finishB
> eanFactoryInitialization(AbstractApplicationContext.java:913)
>        at 
> org.springframework.context.support.AbstractApplicationContext.refresh
> (AbstractApplicationContext.java:464)
>        at 
> org.apache.camel.spring.javaconfig.test.JavaConfigContextLoader.loadCo
> ntext(JavaConfigContextLoader.java:125)
>        at 
> org.springframework.test.context.TestContext.loadApplicationContext(Te
> stContext.java:130)
>        at 
> org.springframework.test.context.TestContext.getApplicationContext(Tes
> tContext.java:148)
>        ... 28 more
> Caused by: java.lang.IllegalArgumentException: host must be specified 
> and not empty
>        at 
> org.apache.camel.util.ObjectHelper.notEmpty(ObjectHelper.java:319)
>        at 
> org.apache.camel.component.file.remote.RemoteFileEndpoint.afterPropert
> iesSet(RemoteFileEndpoint.java:108)
>        at 
> org.apache.camel.component.file.remote.RemoteFileEndpoint.createConsum
> er(RemoteFileEndpoint.java:75)
>        at 
> org.apache.camel.component.file.remote.RemoteFileEndpoint.createConsum
> er(RemoteFileEndpoint.java:31)
>        at 
> org.apache.camel.impl.EventDrivenConsumerRoute.addServices(EventDriven
> ConsumerRoute.java:65)
>        at 
> org.apache.camel.impl.DefaultRoute.onStartingServices(DefaultRoute.jav
> a:80)
>        at 
> org.apache.camel.impl.RouteService.warmUp(RouteService.java:133)
>        at 
> org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelC
> ontext.java:1925)
>        at 
> org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(Def
> aultCamelContext.java:1853)
>        at 
> org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(Defaul
> tCamelContext.java:1646)
>        at 
> org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelCon
> text.java:1534)
>        at 
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.
> java:1421)
>        at 
> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.
> java:179)
>        at 
> org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
>        at 
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.ja
> va:1389)
>        at 
> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelConte
> xt.java:228)
>        at 
> org.apache.camel.spring.SpringCamelContext.afterPropertiesSet(SpringCa
> melContext.java:104)
>        at 
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanF
> actory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
>        at 
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanF
> actory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
>        ... 40 more
>
> -----Original Message-----
> From: Christian Müller [mailto:christian.muel...@gmail.com]
> 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 <claus.ib...@gmail.com> wrote:
>
>> On Wed, May 2, 2012 at 5:21 PM, Ilger Gerda <il...@big.tuwien.ac.at>
>> wrote:
>> > Hi all,
>> >
>> > We have a number of ftp consumer routes that we start based on URLs 
>> > read
>> from our database.
>> > If there's a typo in the URL (e.g. "ftp://localhost::1023";), the 
>> > whole
>> camelContext won't start.
>> > We're using SpringCamelContext.
>> >
>> > These routes are not essential, we still want our application to 
>> > 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=false.
>>
>> But there is currently no option to say, well I dont care if a route 
>> cannot startup.
>>
>>
>> > Thanks,
>> > Gerda
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com 
>> FuseSource
>> Email: cib...@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus, fusenews
>> Blog: http://davsclaus.blogspot.com/
>> Author of Camel in Action: http://www.manning.com/ibsen/
>>



--
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com FuseSource
Email: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Reply via email to