Tools and Technologies used in this article :

  1. Spring Framework 3.2.3

  2. Spring Security 3.1.4

 

Error Stack-trace

Server Console

 

Solution

In Spring Framework 3.2, spring-asm is upgraded to org.objectweb.asm 4.0 and included in spring-core. Now there is no need to add this spring-asm3 dependency separately within the build script. If it is declared, then remove the same while migrating to 3.2.
There are chances that your project is using other spring extension (say Spring Security 3.1.4), which is dependent on spring-asm3. As a result different versions of asm module may be available in the classpath.
When application starts, different versions of classes may get loaded - ClassMetadataReadingVisitor from spring-core (containing asm 4.0) and ClassVisitor from spring-asm (containing asm 3.x). As a result ClassMetadataReadingVisitor violates the contract of interface ClassVisitor and resulting the IncompatibleClassChangeError.

To avoid this, you need to add spring-asm to the exclusion list as shown below.

 

Check for spring-asm Dependency

Go to the project directory in the command prompt and execute mvn dependency:tree

Command Prompt

From the above dependency check, we can see that old spring-asm (org.springframework:spring-asm:jar:3.0.7.RELEASE) will also be loaded along with the new asm included in spring-core (org.springframework:spring-core:jar:3.2.3.RELEASE.

 

Exclude spring-asm Dependency

Now add spring-asm in the exclusion list of each dependent dependency (for example spring-security-core).

pom.xml

Run the maven dependency command again to verify.

Command Prompt

Hopefully, this will resolve your IncompatibleClassChangeError issue, just like mine.

 

References