camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Cook (JIRA)" <>
Subject [jira] [Created] (CAMEL-6463) Camel routes added to context at wrong point of Spring lifecycle
Date Mon, 17 Jun 2013 11:21:21 GMT
Daniel Cook created CAMEL-6463:

             Summary: Camel routes added to context at wrong point of Spring lifecycle
                 Key: CAMEL-6463
             Project: Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 2.9.2
         Environment: Not relevant.
            Reporter: Daniel Cook
            Priority: Minor

We use camel with Java DSL and a lot of spring dependency injection, we context scan to find
the Route Builders.

We have an intermittent problem where camel cannot start due to a null reference being thrown
by a route.  Example code (for illustrative purposes) is:

public class MyRouteBuilder extends RouteBuilder {

private MyService myService;

public void configure() throws Exception {

In the example above occassionally there is a .process(NULL) reference error thrown at runtime;
usually only on quick machines.  I stress this is not a problem with our Spring Dependency
injection config.

After looking at the camel code, including on master, the problem arrises because the AbstractCamelContextFactoryBean
(which the Spring CamelContextFactoryBean extends) installs the routes (calling the route
builder's configure() method) into the context in the afterPropertiesSet() method.  There
is no guarantee that spring will have initialised the service as the Spring Camel Context
does not depend on the bean.  The routes should be installed when spring indicates everything
has been initialised, a ContextRefreshed event.

The workaround is not to autowire services used in routes but 'new' them.  

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message