Tuesday, May 28, 2013

"stack shape inconsistent" error during Spring/Jackson application initialization

I have a JSON-service client that's implemented in Spring and Jackson and deployed on WebSphere Application Server. The client worked properly, but on a single machine I encountered a strange classloading issue during Spring initialization:
java.lang.VerifyError: JVMVRFY012 stack shape inconsistent; class=org/codehaus/jackson/map/ObjectMapper
The reason was having two incompatible dependencies in the effective pom of the project:

    org.codehaus.jackson
    jackson-mapper-asl
    1.4.2



    org.codehaus.jackson
    jackson-mapper-lgpl
    1.9.12

Both of those jars had ObjectMapper class defined, and both ended up in WEB-INF/lib directory. The error was unstable, because on some machines the correct (latest) versions of the libraries took precedence during classloading.