You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Raja15 <ra...@gmail.com> on 2015/09/27 18:32:31 UTC
No applicationContext has been injected
Hi ,
I am probably doing something wrong with spring DSL. I added
camel-config.xml and cxf-config.xml in the web.xml and looks it started both
web services and Camel routes properly.
However when I run a test , it is failing with "No applicationContext has
been injected" error.
After checking the posts I found the below link
http://camel.465427.n5.nabble.com/svn-commit-r935145-camel-trunk-components-camel-spring-src-main-java-org-apache-camel-spring-CamelBea-td509500.html
But not sure what changes do I need to do. Below are the details.
tomcat web.xml:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:camel-config.xml
classpath:cxf-config.xml</param-value>
</context-param>
camel-config.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<contextScan/>
<template id="producer"/>
.....
and some routes
....
</camelContext>
<bean id="appAdapter" class="com.myapp.adapter.RequestAdapter">
<property name="camelContext" ref="camel" />
</bean>
</beans>
appBusinesBeans.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
*<import resource="classpath:camel-config.xml"/>*
<bean id="appService" class="com.myapp.AppService"/>
....
</beans.
I am using some BeanFactory class to load "appService" from
appBusinesBeans.xml . It is part of java code. This "appService"
bean in turn loads the bean "appAdapter" from camel-config.xml
>From tomcat logs it looks camel started properly. See below
Default COnstructor was called
[ReflectionServiceFactoryBean] - Creating Service
{http://app.com/wsdl/CommReport}Report from WSDL:
/WEB-INF/wsdl/commReport.wsdl
[ServerImpl] - Setting the server's publish address to be /CommReport
[SpringCamelContext] - Apache Camel 2.15.2 (CamelContext: camel) is
starting
[ManagedManagementStrategy] - JMX is enabled
[DefaultTypeConverter] - Loaded 183 type converters
[SpringCamelContext] - AllowUseOriginalMessage is enabled. If access to the
original message is not needed, then its recommended to turn this option off
as it may improve performance.
[SpringCamelContext] - StreamCaching is not in use. If using streams then
its recommended to enable stream caching. See more details at
http://camel.apache.org/stream-caching.html
<b>[SpringCamelContext*] - Route: appToExter started and consuming from:
Endpoint[direct://appToExterByName]
[SpringCamelContext] - Total 1 routes, of which 1 is started.
*[SpringCamelContext] - Apache Camel 2.15.2 (CamelContext: camel) *started
in 0.426 seconds
..........
ERROR [AppService] - Runtime Exception....Request failed to process
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'RequestAdapter' defined
in class path resource [camel-config.xml]: Cannot resolve reference to bean
'camel' while setting bean property 'camelContext';
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'camel':
Invocation of init method failed; nested exception is
*java.lang.IllegalArgumentException: No applicationContext has been
injected!*
Below is the Camel source from "CamelContextFactoryBean " that is throwing
the above exception:
public ApplicationContext getApplicationContext() {
308 if (applicationContext == null) {
309 throw new IllegalArgumentException("No applicationContext
has been injected!");
310 }
311 return applicationContext;
312 }
1) I defined "CamelContext". But logs shows "SpringCamelContext". Is that
since I am using Spring DSL
2) In either case can you please help on how do I address the above
applicationContext error.
I can provide any other details if needed.
Thanks
Raja
--
View this message in context: http://camel.465427.n5.nabble.com/No-applicationContext-has-been-injected-tp5772031.html
Sent from the Camel - Users mailing list archive at Nabble.com.