camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Florian Posch <florian.po...@performgroup.com>
Subject AW: Camel Spring Boot: Bean initialization skipped in auto-configuration
Date Thu, 12 Oct 2017 13:01:37 GMT
OK, thanks for clarification.

I'll go ahead and get rid of the camel-http-starter, using http4 is on my refactoring list
anyway.

Cheers,
Florian


-----Ursprüngliche Nachricht-----
Von: Claus Ibsen [mailto:claus.ibsen@gmail.com] 
Gesendet: Donnerstag, 12. Oktober 2017 14:52
An: users@camel.apache.org
Betreff: Re: Camel Spring Boot: Bean initialization skipped in auto-configuration

Mind that camel-http / camel-http-starter is deprecated, you should use camel-http4 or something
else.

On Thu, Oct 12, 2017 at 2:40 PM, Mark Nuttall <mknuttall@gmail.com> wrote:
> Sorry. I guess my reply was not clear.  I wasn't saying it need 
> changes. I was just saying (and i tried it about a year ago) is that 
> Spring Boot needs a little config to expose things "correctly" when using that component.
> That article was the first one i came too when i googled. :(  Maybe it 
> doesn't anymore? :)
>
> I was only trying to figure out what might possible cause the issue he 
> was seeing. And also to give him a work around.
>
> On Thu, Oct 12, 2017 at 8:27 AM, Claus Ibsen <claus.ibsen@gmail.com> wrote:
>
>> On Thu, Oct 12, 2017 at 2:20 PM, Mark Nuttall <mknuttall@gmail.com> wrote:
>> > well that does sound like an issue with the camel-http-starter 
>> > component and would be something for the maintainers.
>> > If i remember rightly, using that component with spring boot 
>> > requires
>> some
>> > minor coding additions to get things to work (i.e. like this - 
>> > http://www.frommknecht.net/spring-boot-meets-apache-camel/). It 
>> > might be related.
>> >
>> > So, what I suggest is just use Spring Controllers instead. It is 
>> > VERY
>> easy
>> > to do and just use the producerTemplate to send thing to camel routes.
>> This
>> > is what I do.
>> >
>>
>> No camel-http-starter does not need any changes.
>> That link your provided is to some old article from 2014.
>>
>> Sure spring-mvc is a good web library and you can easily integrate 
>> with with Camel with producer templates or other means.
>>
>> > On Thu, Oct 12, 2017 at 4:12 AM, Florian Posch < 
>> > florian.posch@performgroup.com> wrote:
>> >
>> >> Hi,
>> >>
>> >> Thanks for your swift reply.
>> >>
>> >> As mentioned in the Stackoverflow question, it is not a matter of
>> generic
>> >> objects like Map<> or Object because injection of a 
>> >> domain-specific
>> class
>> >> doesn't work either.
>> >>
>> >> Finally, I've found out what could potentially cause the problem: 
>> >> For my case, it depends on whether camel-http-starter is on the 
>> >> classpath or
>> not.
>> >> If I remove that dependency MyInflightRepositorys' data field gets 
>> >> injected, otherwise not. Not sure if this makes any sense in the 
>> >> given sample but that changes our application's behaviour...
>> >>
>> >> See https://github.com/DoNuT1985/camel-dependency-sample
>> >>
>> >> I hope this helps.
>> >>
>> >> 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
>> >>
>> >>
>> >> -----Ursprüngliche Nachricht-----
>> >> Von: Mark Nuttall [mailto:mknuttall@gmail.com]
>> >> Gesendet: Mittwoch, 11. Oktober 2017 13:45
>> >> An: users@camel.apache.org
>> >> Betreff: Re: Camel Spring Boot: Bean initialization skipped in 
>> >> auto-configuration
>> >>
>> >> 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.posch@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.posch@performgroup.com
>> >> >
>> >> > Austria
>> >> > Skype rb.fposch
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > W www.performgroup.com
>> >> >
>> >> >
>> >> >
>> >>
>> >> ____________________________________________________________
>> ____________
>> >>
>> >> CONFIDENTIALITY - This email and any files transmitted with it, 
>> >> are confidential, may be legally privileged and are intended 
>> >> solely for the
>> use
>> >> of the individual or entity to whom they are addressed. If this 
>> >> has
>> come to
>> >> you in error, you must not copy, distribute, disclose or use any 
>> >> of the information it contains. Please notify the sender 
>> >> immediately and delete them from your system.
>> >>
>> >> SECURITY - Please be aware that communication by email, by its 
>> >> very nature, is not 100% secure and by communicating with Perform 
>> >> Group by
>> email
>> >> you consent to us monitoring and reading any such correspondence.
>> >>
>> >> VIRUSES - Although this email message has been scanned for the 
>> >> presence
>> of
>> >> computer viruses, the sender accepts no liability for any damage
>> sustained
>> >> as a result of a computer virus and it is the recipient’s
>> responsibility to
>> >> ensure that email is virus free.
>> >>
>> >> AUTHORITY - Any views or opinions expressed in this email are 
>> >> solely
>> those
>> >> of the sender and do not necessarily represent those of Perform Group.
>> >>
>> >> COPYRIGHT - Copyright of this email and any attachments belongs to
>> Perform
>> >> Group, Companies House Registration number 6324278.
>> >>
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> http://davsclaus.com @davsclaus
>> Camel in Action 2: https://www.manning.com/ibsen2
>>



--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

________________________________________________________________________

CONFIDENTIALITY - This email and any files transmitted with it, are confidential, may be legally
privileged and are intended solely for the use of the individual or entity to whom they are
addressed. If this has come to you in error, you must not copy, distribute, disclose or use
any of the information it contains. Please notify the sender immediately and delete them from
your system.

SECURITY - Please be aware that communication by email, by its very nature, is not 100% secure
and by communicating with Perform Group by email you consent to us monitoring and reading
any such correspondence.

VIRUSES - Although this email message has been scanned for the presence of computer viruses,
the sender accepts no liability for any damage sustained as a result of a computer virus and
it is the recipient’s responsibility to ensure that email is virus free.

AUTHORITY - Any views or opinions expressed in this email are solely those of the sender and
do not necessarily represent those of Perform Group.

COPYRIGHT - Copyright of this email and any attachments belongs to Perform Group, Companies
House Registration number 6324278.
Mime
View raw message