Apr 23, 2010

Resolve java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor

Spring 3.0 is emphatically remarkable! When we moved to Spring 3.0, everything worked fine and the team was of course happy! While doing this, we were also trying to move transactions from the old-school way (using hibernate.cfg.xml) to autowiring session factory and making it annotation driven! The latter move forced us to introduce the following code in out applicationContext.xml
<tx:annotation-driven transaction-manager="transactionManager" />


When we thought everything would work, we were surprised to see that on deployment, tomcat reported:
<br />java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor<br />

While this Resolve java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor kept us in surprise, I had to google around a bit! On searching a bit across the Internet, I came across the following solution

Solution:

The previous versions of Spring (<3.0)were shipping AOPAlliance.jar which was required to run the above annotation. In spring 3.0 however, does not come bundles with this jar. As such, if you use Spring 3.0, it is important that you download this jar from this link

Yet another utile pointer that I came across is the fact that there is a JIRA issue to include the AOPAlliance.jar in future releases of Spring! Once I added this jar to the classpath of my application, the Resolve java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor error disappeared!

If you find the information pretty helpful, I would really be happy if you would keep me posted via the comments form displayed under this article! If you had wanted some other information related to the same topic, I would suggest you to drop a note to me using the comments form for that would help me in getting back to you with the details you are in need of!

39 comments:

  1. Thanks,

    Came across the same problem. For others having the same problem please note that the jar, com.springsource.org.aopalliance-1.0.0.jar, is now included in spring-framework-3.0.2.RELEASE-dependencies.zip.

    Cheers

    ReplyDelete
  2. @Anonymous

    Thanks for that pointer! Nice of you to have made us all know about it here!

    ReplyDelete
  3. any idea if it is present spring-framework-3.0.3? I got same exception when we moved to 3.0.3

    ReplyDelete
  4. @Anonymous

    Can you please check if the com.springsource.org.aopalliance-1.0.0.jar is present in your classpath and further let us know in this blog here?

    ReplyDelete
  5. Hello, I'm into the same problem. I use Spring 3.0.3 and I dont find aopalliance.jar bundled with it. Should I get it from Spring 3.0.2 dependencies jar?

    ReplyDelete
  6. @Anonymous

    You can download this jar file from the link below: Let me know if you need more help in this regard!
    http://www.springsource.com/repository/app/bundle/version/detail?name=com.springsource.org.aopalliance&version=1.0.0

    ReplyDelete
  7. thank you verry much man

    ReplyDelete
  8. That is very nice to hear that this helped you!

    ReplyDelete
  9. Cheers for that, I ran into the same problem..no idea why aopalliance was removed from Spring 3 in the first place!

    ReplyDelete
  10. I could build but not deployed. Glassfish has kept throwing the same exception. If you don't mind, where exactly did you make the modification(s), please?

    ReplyDelete
  11. Muchas gracias viejo

    ReplyDelete
  12. thank for your post, it help me to solve above problem. :)

    ReplyDelete
  13. THANK YOU! You saved me ... I had very similar problem when deployng our Spring 3.0.5-based app. to WebLogic 10 server. I included aopalliance.jar, and it solved the exception.

    ReplyDelete
  14. Thanks for the info. Landed directly here from google :)

    ReplyDelete
  15. @tienlong, @PaniniLuncher,@Suresh
    Awesome. Thanks for your feedback

    ReplyDelete
  16. Dead on !! Thanks for your help !!

    ReplyDelete
  17. Hey thank you very much for sharing the solution.

    I had to use Spring 3.0.5, which as of today is the latest release, and I do get this error, so I suppose the jar isn't included.

    Thanks for the timesaver!


    Tanya

    ReplyDelete
  18. Oh yeah, that was it... Thanks a bunch! :)

    ReplyDelete
  19. Thnx a lot :-) did not need to google a lot for it thnx to ur post :))

    warm regards
    Vinod M

    ReplyDelete
  20. You may need cgLib2 to make it work:
    http://sourceforge.net/projects/cglib/files/

    ReplyDelete
  21. Yes thank you think that did it for me as well, on GlassfishESBv2.2

    ReplyDelete
  22. Awesome article!

    ReplyDelete
  23. Wow best post. Thanks, it works for me!

    ReplyDelete
  24. thanks a lot, you helped me solve the problem with spring 3.0.6!

    Gonzalo

    ReplyDelete
  25. Thank you very much for this post. This helped me a lot since I'm new to spring.

    ReplyDelete
  26. I got the same error. Thanks for your post!

    ReplyDelete
  27. Thank you for posting the solution. I had the same issues in Spring 3.1.1! How come Spring's documentation doesn't refer to this !!!

    ReplyDelete
  28. hello, thank you for this post, but, after adding this jar, this error is persisting :( in my spring file,any help??

    ReplyDelete
  29. Hi thank you for the post, but after adding the jar, the error persists in my spring file, and I can not use the annotations :( , please help !

    ReplyDelete
  30. Thanks, i included the jar but the error persists :'(

    ReplyDelete
  31. THanks but sadly it didn't work for me :(

    ReplyDelete
  32. Awsome thank you very much for this information!!

    ReplyDelete
  33. Thanks for you help, this info saved my graduation project :)

    ReplyDelete
  34. thank you ...yaar saved a day

    ReplyDelete