Return-Path: X-Original-To: apmail-camel-issues-archive@minotaur.apache.org Delivered-To: apmail-camel-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 03838C40C for ; Tue, 23 Jul 2013 07:21:02 +0000 (UTC) Received: (qmail 68815 invoked by uid 500); 23 Jul 2013 07:21:01 -0000 Delivered-To: apmail-camel-issues-archive@camel.apache.org Received: (qmail 68728 invoked by uid 500); 23 Jul 2013 07:21:01 -0000 Mailing-List: contact issues-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list issues@camel.apache.org Received: (qmail 68537 invoked by uid 99); 23 Jul 2013 07:20:58 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Jul 2013 07:20:58 +0000 Date: Tue, 23 Jul 2013 07:20:58 +0000 (UTC) From: "Claus Ibsen (JIRA)" To: issues@camel.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (CAMEL-6463) Camel routes added to context at wrong point of Spring lifecycle MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CAMEL-6463?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Claus Ibsen updated CAMEL-6463: ------------------------------- Issue Type: Improvement (was: Bug) > Camel routes added to context at wrong point of Spring lifecycle > ---------------------------------------------------------------- > > Key: CAMEL-6463 > URL: https://issues.apache.org/jira/browse/CAMEL-6463 > Project: Camel > Issue Type: Improvement > Components: camel-core > Affects Versions: 2.9.2 > Environment: Not relevant. > Reporter: Daniel Cook > Assignee: Claus Ibsen > Priority: Minor > Fix For: 2.12.0 > > > 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 { > @Autowired > private MyService myService; > @Override > public void configure() throws Exception { > from(ENDPOINT) > .process(myService) > } > } > 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: http://www.atlassian.com/software/jira