Exception handling _maven Web project Java.lang.LinkageError

Source: Internet
Author: User

The browser runs the project exception as follows:

HTTP Status 500-type Exception reportmessagedescription The server encountered an internal error () that prevented it fro M fulfilling this request.exceptionjava.lang.LinkageError:loader constraint Violation:when resolving interface method " Javax.servlet.jsp.JspApplicationContext.getExpressionFactory () ljavax/el/expressionfactory; "The class loader ( instance of Org/apache/jasper/servlet/jasperloader) of the current class, org/apache/jsp/index_jsp, and the class loader ( instance of Org/apache/catalina/loader/standardclassloader) for resolved class, javax/servlet/jsp/ Jspapplicationcontext, with different Class objects for the type p.jspapplicationcontext.getexpressionfactory () ljavax/ El/expressionfactory; Used in the Signatureorg.apache.jsp.index_jsp._jspinit (index_jsp.java:31) Org.apache.jasper.runtime.HttpJspBase.init (httpjspbase.java:49) Org.apache.jasper.servlet.JspServletWrapper.getServlet (jspservletwrapper.java:181) Org.apache.jasper.servlet.JspServletWrapper.service (Jspservletwrapper. java:370) Org.apache.jasper.servlet.JspServlet.serviceJspFile (jspservlet.java:389) Org.apache.jasper.servlet.JspServlet.service (jspservlet.java:333) Javax.servlet.http.HttpServlet.service ( httpservlet.java:722) Org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter (  STRUTSPREPAREANDEXECUTEFILTER.JAVA:96) Note the full stack trace of the root cause are available in the Apache tomcat/7.0.22 Logs.

Just see the anomaly a little bit, ljavax/el/expressionfactory what ghost, my Servlet-api.jar and Jsp-api.jar have AH

<dependency> <groupId>org.apache.tomcat</groupId> <artifactid>servlet-api</artifactid > <version>6.0.37</version></dependency><dependency> <groupid>javax.servlet.jsp </groupId> <artifactId>jsp-api</artifactId> <version>2.1</version></dependency >

Through the online explanation is tomcat1.7 in the Servlet-api.jar package, Jsp-api.jar and so on their own Lib Jar has conflict

Solution is to get rid of the conflicting jar packages in Lib in your project

But the problem comes again, it is the MAVEN project restart can not find the relevant jar package, Start no error?

All right, then I'll set the package to the scope of provided.

<dependency> <groupId>org.apache.tomcat</groupId> <artifactid>servlet-api</artifactid > <version>6.0.37</version> <scope>provided</scope></dependency><dependency > <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version >2.1</version> <scope>provided</scope></dependency>

Re-release, start Tomcat, run, success, thank God

Ps_maven_scope:

In Pom 4,<dependency> in <scope> it mainly manages dependent deployments, currently <scope> can use 5 values  * Compile: Default, applies to all stages and will be published along with the project  * Provided: similar to compile, expect JDK, container or user to provide this dependency, such as Servlet.jar  * Runtime: Only used at runtime, such as JDBC driver, applicable run and test phase  * Test: Used only during testing, to compile and run test code, not to publish with Project  * System: Similar to provided, need to explicitly provide a jar,maven that contains dependencies does not find it in repository

Exception handling _maven Web project Java.lang.LinkageError

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.