mystarrocks
mystarrocks

Reputation: 4088

Easymock3 Spring4.0.0.RELEASE cglib compatibility

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.

Upvotes: 0

Views: 777

Answers (1)

Anadi
Anadi

Reputation: 1

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

Upvotes: 0

Related Questions