• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Basic Autowiring Mismatch

 
Ranch Hand
Posts: 176
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

I have been working with Spring for a while now. I have felt my way around rather than learned via certification. One thing that I have not figured out yet is this scenario.

I have an endpoint 'GlenEndpoint' annotated with @Endpoint.

'GlenEndpoint' has an Autowired service 'IrisService'. IrisService is itself annotated with @Service.

This works well as long IrisService instantiates any dependencies as POJO's in the old fashioned way. Eg,



However, if I attempt to autowire the AmountOwedUtil object, the application can not start up correctly, complaining that there is no qualifying bean of this type. This happens even though I have annotated the AmountOwedUtil class with @Service. I have also made sure that all relevant packages are covered by component scanning. I should mention that AmountOwedUtil is in a separate package to both IrisService and GlenEndpoint.

I know that this is likely something very simple, but so far it has me banging my head against the wall  

Please help,

G
 
Ranch Hand
Posts: 270
15
Android Angular Framework Spring AngularJS Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Glen.
I am actually more new to Spring (at least any recent version) than yourself.  So, first I'd like to ask: given you annotated IrisService as @Service, have you injected it using @Autowire?  If so, it probably means the word "bean" is not the problem.  That is, a service is a bean.

However, did you do any research on whether this might be some kind of order dependency?

Finally, I have not looked at "@Service" yet.  Still learning.  I have seen @Component, and that is treated as a bean.

HTH
 
Glen Iris
Ranch Hand
Posts: 176
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

L Foster wrote:Hi, Glen.
given you annotated IrisService as @Service, have you injected it using @Autowire?



Yes  

L Foster wrote:
However, did you do any research on whether this might be some kind of order dependency?


no. It seems to me that I cannot autowire a dependency into class that is itself, autowired into somewhere else. Makes no sense and I am sure I am doing something ridiculous. As a work around, I have just instantiated the dependencies using old fashioned Java. Object x = new Object();

L Foster wrote:
Finally, I have not looked at "@Service" yet.  Still learning.  I have seen @Component, and that is treated as a bean.



This may be the blind leading the blind here but AFAIK, @Service is just a more specialised version of @Component.
reply
    Bookmark Topic Watch Topic
  • New Topic