Results 1 to 3 of 3

Thread: @Resource referencing a transactional @Service Bean

  1. #1
    Join Date
    Apr 2006
    Posts
    4

    Default @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.

    Cheers
    Michael

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Apr 2006
    Posts
    4

    Default @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!!

    Michael

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •