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 componentScan 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. Per Camel's reference guide, 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 and tries to instantiate it. 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 componentScan, 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>. Am I doing it incorrectly? Thanks for any help! -- View this message in context: http://camel.465427.n5.nabble.com/Having-issue-with-componentScan-excludes-tp5768709.html Sent from the Camel - Users mailing list archive at Nabble.com.