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 8882C18AE3 for ; Wed, 1 Jul 2015 15:25:48 +0000 (UTC) Received: (qmail 63102 invoked by uid 500); 1 Jul 2015 15:25:48 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 63053 invoked by uid 500); 1 Jul 2015 15:25:48 -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 63035 invoked by uid 99); 1 Jul 2015 15:25:47 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Jul 2015 15:25:47 +0000 X-ASF-Spam-Status: No, hits=0.6 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of claus.ibsen@gmail.com designates 209.85.213.178 as permitted sender) Received: from [209.85.213.178] (HELO mail-ig0-f178.google.com) (209.85.213.178) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Jul 2015 15:23:34 +0000 Received: by igrv9 with SMTP id v9so76531205igr.1 for ; Wed, 01 Jul 2015 08:25:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=gAAH7AC80DfoP3BMES1KpLc0x3maGi31VBtbeO8mWnE=; b=ry43K34qTRk3zBbl/qdMMWPTBnN5fciaN9Knql3IvMv6QDwKSBjhD9CayCWYf9OClX Zylrv01hvb3FGzNTamq2RYJWJ+o/8DoHwvwl31yloM2FFINcKl10OAp6esq6yVwpAzTi dyZsxwEJ378ZGnEbqswksod2gh5OQ+sNLY69OR2BEjBl1SbVDeBl2v/Re1aVd1chpPSe IAG8sn4FGaKrZ4XcINEmXgQwcwtNHXlvBZZ/9ZR4Ng/cxKfWYwmnvYxAx84xywxG5zyc m98I83RYPfy1Ww77KXmx71Gp40NdBb5Cg3pbXgUM+aQ4BgecVFBRZ4wteoA2rWWcIlBk inKQ== X-Received: by 10.107.134.16 with SMTP id i16mr39815933iod.6.1435764321652; Wed, 01 Jul 2015 08:25:21 -0700 (PDT) MIME-Version: 1.0 Received: by 10.79.69.195 with HTTP; Wed, 1 Jul 2015 08:25:02 -0700 (PDT) In-Reply-To: <1435763071988-5768755.post@n5.nabble.com> References: <1435763071988-5768755.post@n5.nabble.com> From: Claus Ibsen Date: Wed, 1 Jul 2015 17:25:02 +0200 Message-ID: Subject: Re: Excluding prototype-scoped @Component route builder from ? To: "users@camel.apache.org" Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org Hi Try without line breaks in that so there is no line breaks / spaces etc. On Wed, Jul 1, 2015 at 5:04 PM, furchess123 wrote: > Hi, > I am using Camel 2.14.2. All my RouteBuilder implementations are @Component > annotated Spring beans, auto-wired with processors, error handlers, > AggregationStrategy implementation beans, etc. I have been using > *contextScan* to load these Spring beans into Camel context. However, I have > one route builder implementation that is a prototype-scoped Spring bean, > distinct instances of which may have to be created on-demand at runtime. It > must NOT be component-scanned at startup. > > Per Camel's reference guide > , I have tried to > exclude that particular class from being component-scanned by Camel using > the following: > > > > * > com.myco.something.route.MyExcludedRouteBuilder > * > > > > *This doesn't work.* Camel doesn't seem to ignore this route builder class > and tries to instantiate it at startup. I don't provide a no-arg constructor > for that class (instances are requested from the Spring context on demand > with a specific "from" endpoint value) so CamelContextFactoryBean throws the > following exception: > > ... > Caused by: org.springframework.beans.factory.BeanCreationException: Error > creating bean with name 'MyExcludedRouteBuilder' defined in file > [.../route/MyExcludedRouteBuilder.class]: Instantiation of bean failed; > nested exception is org.springframework.beans.BeanInstantiationException: > Could not instantiate bean class > [com.myco.something.route.MyExcludedRouteBuilder]: No default constructor > found; nested exception is java.lang.NoSuchMethodException: > com.myco.something.route.MyExcludedRouteBuilder.() > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1095) > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1040) > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:505) > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) > at > org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) > at > org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198) > at > org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:489) > at > org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1060) > at > org.apache.camel.spring.ContextScanRouteBuilderFinder.appendBuilders(ContextScanRouteBuilderFinder.java:49) > at > org.apache.camel.spring.CamelContextFactoryBean.findRouteBuildersByContextScan(CamelContextFactoryBean.java:233) > at > org.apache.camel.core.xml.AbstractCamelContextFactoryBean.findRouteBuilders(AbstractCamelContextFactoryBean.java:881) > at > org.apache.camel.core.xml.AbstractCamelContextFactoryBean.setupRoutes(AbstractCamelContextFactoryBean.java:344) > at > org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(*CamelContextFactoryBean.java:326*) > ... 56 more > Caused by: org.springframework.beans.BeanInstantiationException: Could not > instantiate bean class [com.myco.something.route.MyExcludedRouteBuilder]: No > default constructor found; nested exception is > java.lang.NoSuchMethodException: > com.myco.something.route.MyExcludedRouteBuilder.() > at > org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:85) > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1088) > ... 68 more > Caused by: java.lang.NoSuchMethodException: > com.myco.something.route.MyExcludedRouteBuilder.() > at java.lang.Class.getConstructor0(Class.java:2892) > at java.lang.Class.getDeclaredConstructor(Class.java:2058) > at > org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:80) > ... 69 more > > > I cannot find an example of using /excludes/ with /contextScan/, other than > what I see here: > http://camel.apache.org/spring.html > > It states that I can use the same ANT-style patterns to exclude/include > classes as with //. I have tried wild cards as well as > specifying the full class name explicitly (as shown in the example above.) > Nothing excludes the class during Camel's context scanning. Why? Am I doing > it incorrectly? Or is it a bug? > > Thanks for any help! > > > > -- > View this message in context: http://camel.465427.n5.nabble.com/Excluding-prototype-scoped-Component-route-builder-from-contextScan-tp5768755.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen ----------------- Red Hat, Inc. Email: cibsen@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/