whboyd

duplicate class definition error when using spring proxies in a building block

Discussion created by whboyd on Aug 21, 2015
Latest reply on Aug 25, 2015 by whboyd

I am curious as to whether anyone else has seen this or found a solution to it.

 

Whenever I try to use features of spring that require cglib proxies in a building block, I get this error when the building block tries to start in Bb:

java.lang.LinkageError: loader (instance of  blackboard/tomcat/servletcontainer/PlugInOverrideClassLoader): attempted  duplicate class definition for name: "edu/liberty/lms/skeletron/web/hello/HelloController$$EnhancerBySpringCGLIB$$35372c31"
  at java.lang.ClassLoader.defineClass1(Native Method)
  at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
  ... 69 more

In this case, the class it is trying to generate a cglib proxy for is a controller that has @PreAuthorized annotations for security, and my security configuration has prePostEnabled and proxyTargetClass turned on.

It looks to me like something weird might be going on with Bb's custom class loader because I don't get this error when running the same application on plain tomcat 7.

 

I have also seen this error message appear when using aop advice, something which likewise uses cglib class proxying.

 

Anyone have any ideas?

Outcomes