-
Sep 10th, 2009, 02:20 AM
#1
@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
-
Sep 10th, 2009, 03:30 AM
#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.
-
Sep 10th, 2009, 04:39 AM
#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!!
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
-
Forum Rules