Announcement Announcement Module
Collapse
No announcement yet.
Problems after introducing CGLIB dependency Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems after introducing CGLIB dependency

    I have successfully used Spring AOP with JDK Dynamic Proxies in the Service/DAO layers of our application. I want to introduce Advice around our Controllers. However, we are using Spring MVC and annotated controllers that do not implement any interface. Therefore, I need to introduce CGLIB as a dependency in order to do this.

    My problem is that when I simply introduce CGLIB as a dependency in my project (cglib-nodep.jar) without adding any Advice then I'm encountering errors with autoboxing that did not occur before. I have a TO with a primitive int property (call it foo). A piece of code is calling the setter with an Integer variable that is null.

    Integer myNullInt = nulll;
    mySample.setFoo(myNullInt);

    We're on JDK 5 and this code ran without error before I introduced the CGLIB dependency. I know that I can fix the code...but my concern is that it seems risky to introduce CGLIB on the project given that I don't know what other error might arise when I do (with a large legacy code base).

    Has anyone run into similar problems with CGLIB?

    Is there a better solution to adding advice around Annotated Controllers using JDK Dynamic Proxies so that I can avoid using CGLIB? Is it still considered good practice to create Interfaces for Controllers? One possible route I might follow is to use HandlerInterceptors instead of SpringAOP to do what I need to do around the Controllers.

  • #2
    you can try a hand on aspectJ instead of spring aop

    -Hetal

    Comment

    Working...
    X