prabakar
prabakar

Reputation: 1

HTTP Status 500 - java.lang.LinkageError

I am developing an MVC web application in java using spring framework and maven tool using .

I am getting the following error when i am running my application.

HTTP Status 500 - java.lang.LinkageError: loader constraint violation: when resolving method 
"org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(Ljavax/servlet/ServletConfig;)Lorg/apache/tomcat/InstanceManager;" the class loader (instance of org/apache/jasper/servlet/JasperLoader) of the current class, 
org/apache/jsp/redirect_jsp, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for the method's defining class, 
org/apache/jasper/runtime/InstanceManagerFactory, have different Class objects for the type org/apache/tomcat/InstanceManager used in the signature

Upvotes: 0

Views: 4069

Answers (4)

Jay
Jay

Reputation: 1

As mentioned in previous posts, it should be due to conflicting libraries in your project (jsp-api, servlet-api, el-api etc) which you need to exclude.

If you are using spring-boot, you need to exclude tomcat libs when you are generating a war to be deployed in tomcat.

For ex.

<exclusion>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
<exclusion>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-el</artifactId>
</exclusion>

Upvotes: 0

D.B.
D.B.

Reputation: 4713

Based on the error you posted, the classloader that is loading org/apache/jsp/redirect_jsp, and the class loader for
org/apache/jasper/runtime/InstanceManagerFactory, have different Class objects for the type org/apache/tomcat/InstanceManager which means you are referencing a jar that contains org.apache.tomcat.InstanceManager in two different class loaders and those loaders have a delegation relationship. Class objects are unique based on their fully qualified class name and their loader.

Here is a pretty good article to read about this type of error.

You need to find out how you are loading the class twice and modify your setup so that you only load it once.

Upvotes: 0

Naveen Ramawat
Naveen Ramawat

Reputation: 1445

Is there servlet-api.jar is part of war file ? Please remove it during deployment because every webserver has there own servlet-api implementation. So only use it in your code for compilation purpose.

Upvotes: 2

Vimal Bera
Vimal Bera

Reputation: 10497

You have server specific jar files in your WEB-INF/lib folder of your web application. For ex : jsp-api.jar, el-api.jar, servlet-api.jar etc. You need to remove exclude all these if you are using maven for dependency management.

And after removing it, if you are getting compilation error in your code, then add server runtime from Project properties.

Upvotes: 4

Related Questions