I looked at stacktrace and your code here. I agree with the comment about
the Map. The same thing can happen with strings. I am not sure what the map
does but you might be able to that in Spring properties. If not, either
create a class to hold the map and make that class the Bean or provide a
name to the Bean and make sure you use that when you inject the bean.

I think we are going to need a copy of code that does not work. I use
Spring Boot and Camel pretty extensively and while it is not without
issues, it was usually due to me doing something probably I shouldnt have
or there was a better way. :)

Also, as suggested, use constructor injection. The version of Boot you are
using makes it very easy - all you need is a single constructor on your
managed object (to include the RouteBuilder). And if you use Lombok, it is
even easier.

Mark

On Wed, Oct 11, 2017 at 4:41 AM, Florian Posch <
florian.po...@performgroup.com> wrote:

> 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.po...@performgroup.com
>
> Austria
> Skype rb.fposch
>
>
>
>
> W www.performgroup.com
>
>
>

Reply via email to