File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes Injecting non-Spring beans & Spring AOP not work together? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Injecting non-Spring beans & Spring AOP not work together? " Watch "Injecting non-Spring beans & Spring AOP not work together? " New topic
Author

Injecting non-Spring beans & Spring AOP not work together?

Eric Xin Zhang
Greenhorn

Joined: May 21, 2009
Posts: 6
Dear all,

I'm a greenhorn in Spring, and reading the book of Spring in Action 2nd Edition now. I got following problem when following the examples in the book and attempting to mix injecting non-Spring beans with normal Spring AOP features. Related chapters in the book are 3.3 and 4.3.

Source codes & configurations are (some simple classes are omitted):

1. I defined Magician class as following. Please note in order o make injecting non-Spring beans work, the annotation is added:



2. The MagicBox implementation class is:



3. Audience class for the aspect is:



4. Configurations are:



5. Test codes are:



And I run the codes with following VM argument:



Before applying the aop, both harry & lisa work perfectly well. However, after I added aop configurations, I got following output:



As you can see, harry still works but error happens at



I also noticed that if I move the section starting with



to the position before the definition of harry, then even harry cannot work.

Could anybody enlighten me on this. Thank you!
Eric Xin Zhang
Greenhorn

Joined: May 21, 2009
Posts: 6
Hi! Can anybody help me?

Although the codes looks a bit length but you can just copy and paste them to try

BTW, I'm using Spring framework 2.5.6, all jar files are from spring-framework-2.5.6.SEC01-with-dependencies.zip.
Namkere Akpabio
Greenhorn

Joined: Oct 15, 2012
Posts: 1
Hi Eric,
Were you able to solve this problem? Can you please share the solution
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1648
    
    7

Namkere,

This post is quite old and I doubt the original poster is following it anymore. Are you still using Spring 2.5 or are you using a more current version? Please post a more detailed description of your problem (what you are trying to do and what it happening) and we can try to help you with it.


[How To Ask Questions][Read before you PM me]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Injecting non-Spring beans & Spring AOP not work together?