camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raja15 <>
Subject No applicationContext has been injected
Date Sun, 27 Sep 2015 16:32:31 GMT
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

But not sure what changes do I need to do.  Below are the details.

tomcat web.xml:

<beans xmlns=""
  <camelContext id="camel" xmlns="">
    	<template id="producer"/>
     and some routes

	<bean id="appAdapter" class="com.myapp.adapter.RequestAdapter">
		<property name="camelContext" ref="camel" />


<beans xmlns=""
	*<import resource="classpath:camel-config.xml"/>*
       <bean id="appService" class="com.myapp.AppService"/>

 I am using some BeanFactory class to load &quot;appService&quot; from
appBusinesBeans.xml . It is part of java code. This &quot;appService&quot;
bean in turn loads the  bean &quot;appAdapter&quot; from camel-config.xml

>From tomcat logs it looks camel started properly.  See below

Default COnstructor was called
[ReflectionServiceFactoryBean] - Creating Service
{}Report from WSDL:
 [ServerImpl] - Setting the server's publish address to be /CommReport
 [SpringCamelContext] - Apache Camel 2.15.2 (CamelContext: camel) is
 [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
 &lt;b>[SpringCamelContext*] - Route: appToExter started and consuming from:
[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

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. 


View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message