Reputation: 173
I am upgrading from Java 8 to Java 11. Even Spring version used earlier was 4.x now I have upgraded to Spring 5.x
I am using camel for routes
My camel context file is as follows
<bean id="samplePriceBean"
class="com.abc.SamplePriceBean">
<constructor-arg index="0"
ref="route1" />
<constructor-arg index="1"
ref="route2" />
<constructor-arg index="2"
ref="myCamelContext" />
<constructor-arg index="3" value="route1" />
<constructor-arg index="4" value="route1" />
</bean>
<camelContext id="myCamelContext" xmlns="http://camel.apache.org/schema/spring">
<route id="listRoute" autoStartup="false">
<from
uri="file:{{abc.list}}?noop=true&" />
<to uri="direct:route1"
id="route1" />
</route>
<route id="readRoute" autoStartup="false">
<from
uri="file:{{abc.read}}?noop=true&" />
<to uri="direct:route2"
id="route2" />
</route>
</camelContext>
Now when I run the application error in console as follows
Error creating bean with name 'samplePriceBean' defined in class path resource [app-camel.xml]: Cannot resolve reference to bean 'route1' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'route1' available
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:787)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:226)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1358)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1204)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
The application is unable to resolve the routes defined in camel context
I am using JDk 11 , SPring 5.x, Apache camel 3.0.0
Upvotes: 0
Views: 633
Reputation: 55545
Okay so this is really wrong from the beginning too
The <route>
is for defining routes, and routes are not exposed as spring bean which spring dependency injection can use/lookup. Only <camelContext>
is intended for that, as its CamelContext
.
In your SamplePriceBean
you can change its constructor to not take in route1 and route2 as refs, but you can just use the API from CamelContext
to lookup these routes via CamelContext
API (not spring bean ids).
Upvotes: 1
Reputation: 55545
Camel 2.x does NOT support Java 11. You should use Camel 3 for Java 11 support.
Upvotes: 0