Hi Try without line breaks in that <excludes> so there is no line breaks / spaces etc.
On Wed, Jul 1, 2015 at 5:04 PM, furchess123 <[email protected]> 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 > <http://people.apache.org/~dkulp/camel/spring.html> , I have tried to > exclude that particular class from being component-scanned by Camel using > the following: > > <camelContext xmlns="http://camel.apache.org/schema/spring"> > <contextScan> > *<excludes> > com.myco.something.route.MyExcludedRouteBuilder > </excludes>* > </contextScan> > </camelContext> > > *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.<init>() > 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.<init>() > 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.<init>() > 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 /<packageScan>/. 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: [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/
