Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring AOP issue

 
Vijay Kumar
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am new to spring.

Downloaded spring-framework-3.1.0.RC1 and trying to create a simple aop based program.

Please see spring configuration file Application.xml




As mentioned in configuration file, I am using POJO based aspect, but while running my sample program I am facing below exception



i am wondering why this class is not present in spring 3.1. On web I was suggested to add 'aopalliance-1.0.jar'. I add this but after that I got below exception and was suggested to add - aspectjweaver.jar.



I am not sure why spring is asking me to include aspectj jars. Even though I am using POJO base aop. looks like there is an internal dependencies. If I am downloading the complete package of spring then all the libraries must be present in that.


Thanks for reading this.

Thanks,
Vijay
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because Spring AOP is based on AspectJ AOP project, and therefore some of the classes and stuff are defined by AspectJ and not in Spring. So you have to include some AspectJ jar files. Basically Spring is using some 3rd party classes to implement Spring AOP and they come from AspectJ.

Hope that helps clear things up for you.

Good Luck

I also recommend doing Spring AOP with Annotations, it is much simpler to configure than the xml stuff you are doing. (You still need the AspectJ jars)

Mark
 
Vijay Kumar
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark,


So even I am using POJO base AOP, I need AspectJ and associated jar.

I am not sure who can answer it - Why spring library does not include the dependent jars?

Thanks
Vijay
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vijay

Why should Spring contain all dependent jars? When you download any jar, it will normally tell you what other libraries it requires to run.

I think when you use something like Apache Maven, you begin to see the true use of jar files and their dependency on other libraries.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vijay Kumar wrote:Thanks Mark,


So even I am using POJO base AOP, I need AspectJ and associated jar.

I am not sure who can answer it - Why spring library does not include the dependent jars?

Thanks
Vijay


Not sure what you mean by POJO base AOP, as for me all my Aspect classes are POJOs, actually all my classes are POJOs.
Spring AOP is a subset of AspectJ and requires some AspectJ jars in the classpath.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic