This is a problem of shared libraries between between server and web application.
In java a class is identified by its name (including package name) and its class loader (which loaded it). So if you have the same MyBean.class
inside web application WEB-INF/classes
and also inside ${catalina.home}/lib
, these will be viewed as two different classes (i.e. myBean instanceof MyBean == false
). When JVM approaches situation where some class is using class XYZ in its method signatures and XYZ is loaded by a different classloader than a class XYZ known by the current class loader, then LinkageError
is raised.
You problem is that you have Spring dependencies (at least spring-tx) on the shared / system class loader and also within web application dependencies.
To solve your issue you need to do one of the following:
- remove Spring dependencies from server class-loaders
- remove duplicate dependency from the web application (mark it as
provided
dependency in POM) - add duplicate dependencies on
endorsed
class-loader (by that web application class-loader will ignore the web application dependency).