Announcement Announcement Module
No announcement yet.
@Resource referencing a transactional @Service Bean Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Resource referencing a transactional @Service Bean

    Hi People,

    I have a service class annotated with @Service. In that I class I have a method annoated with @Transactional. So, nothing special and all works fine. I use Spring Transaction definied through my application context xml. Everything is default.

    I want to you use somewhere else @Resource to injected that service object into a field object. The Exception I get is that my field object is of type service-class but should be of some dynamically created proxy class. The only way around this problem which I tried is to use appcontext.getBean("...").

    Or do I miss something here?

    Any help is highly appreciated.


  • #2
    You should never program against the concrete class, use the interface and don't cast to the concrete class. If you don't implement a business interface use classproxies instead.


    • #3
      @Resource referencing a transactional @Service Bean

      Hi Marten,

      thanks, that's it. The field which is annotated with @Resource and references a @Service bean is an interface now, and now it works fine!!!

      Great support, thank you very much!!