Easymock3 Spring4.0.0.RELEASE cglib compatibility

僤鯓⒐⒋嵵緔 提交于 2019-12-12 04:39:09

问题


I followed the advice given here to try some unit tests with spring aop enabled methods. However, I suspect that the repackaged cglib classes under spring-core and the cglib-nodep-2.2.jar conflict with each other, causing my class being proxied to be loaded by the classloader twice. This results in the following error:

Caused by: java.lang.LinkageError: loader (instance of  sun/misc/Launcher$AppClassLoader): attempted  duplicate class definition for name:

Tools:

  1. easmock-3.0 (with cglib-nodep-2.2.jar transitive dependency)
  2. spring-x-4.0.0.RELEASE (with repackaged cglib of version ? classes)
  3. junit-4.8.1

Excluding the transitive cglib-nodep dependency didn't help obviously - all tests including non-sring-aop ones started failing too.

I tried the answer posted here too: cleaning up the target folder before running the tests again with no success.

Is this problem really because of the conflict of cglib versions like I thought it would be? If so, what is the right version I should use that would stop loading my class twice.


回答1:


<properties>
    <java.version>1.7</java.version>
    <spring.version>4.0.3.RELEASE</spring.version>
    <cglib.version>2.2.2</cglib.version>
</properties>


来源:https://stackoverflow.com/questions/21755291/easymock3-spring4-0-0-release-cglib-compatibility

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!