camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Florian Posch <florian.po...@performgroup.com>
Subject Camel Spring Boot: Bean initialization skipped in auto-configuration
Date Wed, 11 Oct 2017 08:41:20 GMT
Hi,

I'm using Camel 2.19.3 and Spring Boot 1.5.7 including the corresponding Camel starter for
my application and am having some issues with a custom InflightRepository getting set up.

It is defined as Spring @Component and should get applied to the context by auto-configuration
but the problem is that the bean isn't properly initialized

	@Component
	public class MyInflightRepository extends DefaultInflightRepository {
	
		@Autowired
		private MyInjectedBean bean;
	
		// ...
	}


The repository gets applied to the CamelContext as well as it is available but to me it looks
as if premature bean access in CamelAutoConfiguration.afterPropertiesSet  causes the bean
not being initialiized properly (so @Autowired members remain null but Spring starts up without
an error). As far as I understood this happens because Application.getBeansByType(...) gets
called before all property resolvers are initialized.

I was able to work around that by manually initializing my InflightRepository and setting
it in a CamelConfiguration bean but for my taste this is a bit dangerous to scan for custom
beans that might not get initialized properly during startup.

There's a more detailed snippet given on my Stackoverflow post: https://stackoverflow.com/questions/46680985/spring-boot-camel-autowiring-issues-in-camel-components


Any question, please let me know...

Kind regards,
Florian

Florian Posch // Software Engineer











T   -

RunningBall Sports Information GmbH 
M  -

Plabutscher Straße 63 
F   -

8051 Graz 
E   florian.posch@performgroup.com 

Austria 
Skype rb.fposch




W www.performgroup.com



Mime
View raw message