Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Eric Xin Zhang
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eric,
Were you able to solve this problem? Can you please share the solution
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic