Tomcat 7 LinkageError: violation of bootloader restriction

INFO: Deploying web application archive test-1.0-SNAPSHOT.war 20-Sep-2011 12:08:42 org.apache.catalina.loader.WebappClassLoader validateJarFile INFO: validateJarFile(C:\software\apache-tomcat-7.0.21\webapps\test-1.0-SNAPSHOT\WEB-INF\lib\servlet-api-2.5.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class 20-Sep-2011 12:08:42 com.sun.faces.config.ConfigureListener contextInitialized INFO: Initializing Mojarra 2.1.0 (SNAPSHOT 20100817) for context '/test-1.0-SNAPSHOT' 20-Sep-2011 12:08:42 com.sun.faces.spi.InjectionProviderFactory createInstance INFO: JSF1048: PostConstruct/PreDestroy annotations present. ManagedBeans methods marked with these annotations will have said annotations processed. 20-Sep-2011 12:08:43 com.sun.faces.config.ConfigureListener contextInitialized SEVERE: Critical error during deployment: java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory;" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, com/sun/faces/config/ConfigureListener, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ExpressionFactory used in the signature at com.sun.faces.config.ConfigureListener.registerELResolverAndListenerWithJsp(ConfigureListener.java:684) at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:240) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) 20-Sep-2011 12:08:43 org.apache.catalina.core.StandardContext listenerStart SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener java.lang.RuntimeException: java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory;" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, com/sun/faces/config/ConfigureListener, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ExpressionFactory used in the signature at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:290) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory;" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, com/sun/faces/config/ConfigureListener, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ExpressionFactory used in the signature at com.sun.faces.config.ConfigureListener.registerELResolverAndListenerWithJsp(ConfigureListener.java:684) at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:240) ... 8 more 20-Sep-2011 12:08:43 org.apache.catalina.core.StandardContext startInternal SEVERE: Error listenerStart 20-Sep-2011 12:08:43 org.apache.catalina.core.StandardContext startInternal SEVERE: Context [/test-1.0-SNAPSHOT] startup failed due to previous errors 

I am trying to run mkyong hello world JSF2 example http://www.mkyong.com/jsf2/jsf-2-0-hello-world-example/

POM.xml

 <dependency> <groupId>com.sun.faces</groupId> <artifactId>jsf-api</artifactId> <version>2.1.0-b03</version> </dependency> <dependency> <groupId>com.sun.faces</groupId> <artifactId>jsf-impl</artifactId> <version>2.1.0-b03</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.1</version> </dependency> <dependency> <groupId>com.sun.el</groupId> <artifactId>el-ri</artifactId> <version>1.0</version> <scope>provided</scope> </dependency> 

This thread violating bootloader restrictions describes the same problem in tomcat 6, but it does not help to solve my problem.

+7
source share
4 answers

I don't do Maven, but given Pascal Tiwen's answer in a question related to you, it seems that you need to mark the Maven dependency as provided whenever the target runtime already sends it to the field.

Tomcat as a simple servlet container comes with JSP, Servlet and EL out of the box (only with JSF and JSTL). The exception message you received indicates a duplication of the JSP API in the classpath. I suggest also setting the JSP and Servlet pom.xml in pom.xml to provided .

Next, you will get a second serious problem after fixing the problem, as indicated in the question, Mojarra 2.1.0 does not work in Tomcat . Update Mojarra 2.1.1 or later (it is currently 2.1.3). See Also Mojarra Download Page for pom fragments.

+8
source

a comment

 <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.1</version> </dependency> 

did the trick for me. It looks like jsp has already been provided, adding that the dependency is not needed and creates an error

0
source

This answer is in addition to BalusC's answer. hope this helps.

Use Tomcat 7 as a container. You should consider standard shared library files .

For me, there are such files in the $TOMCATHOME/lib directory:

  • annotations-api.jar
  • catalina- ant.jar
  • Catalina-ha.jar
  • ...
  • Jsp-api.jar
  • servlet-api.jar
  • ...

This is why you should mark servlet-api, jsp-api and el-ri as provided or even exclude JAR.

0
source

Try putting your jar file in your project BuildPath-> Configure BuildPath-> Libraries-> Add External Jar ..

-one
source

All Articles