升级到tomcat 8时出错,严重:Servlet jsp的Servlet.service()抛出异常

时间:2018-06-22 01:55:17

标签: jsp java-8 tomcat8

在运行从tomcat7到tomcat7 / java7到java8的升级项目时遇到麻烦。我有这些错误

java.lang.LinkageError:违反加载程序约束:解决方法“ org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(Ljavax / servlet / ServletConfig;)Lorg / apache / tomcat / InstanceManager;“当前类org / apache / jsp / WEB_002dINF / pages / index_jsp的类加载器(例如org / apache / jasper / servlet / JasperLoader的实例)和类加载器(例如org / codehaus / plexus / classworlds / realm /该方法的定义类org / apache / jasper / runtime / InstanceManagerFactory的ClassRealm)对于签名中使用的org / apache / tomcat / InstanceManager类型具有不同的Class对象

这是我的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>org.springframework.samples.service.service</groupId>

<artifactId>crmdev</artifactId>

<version>0.0.1-SNAPSHOT</version>

<packaging>war</packaging>

<properties>

    <!-- Generic properties -->
    <java.version>1.8</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

    <!-- Web -->
    <jsp.version>2.2</jsp.version>
    <jstl.version>1.2</jstl.version>
    <servlet.version>3.0.1</servlet.version>

    <!-- Spring -->
    <spring-framework.version>4.0.3.RELEASE</spring-framework.version>
    <spring.security.version>3.2.9.RELEASE</spring.security.version>

    <!-- Hibern ate / JPA -->
    <hibernate.version>4.3.5.Final</hibernate.version>

    <!-- Logging -->
    <logback.version>1.0.13</logback.version>
    <slf4j.version>1.7.5</slf4j.version>

    <!-- Test -->
    <junit.version>4.11</junit.version>

</properties>

<dependencies>

    <!-- Spring MVC -->
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-jasper</artifactId>
        <version>8.0.20</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring-framework.version}</version>
    </dependency>

    <!-- Other Web dependencies -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>${jstl.version}</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>${servlet.version}</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>${jsp.version}</version>
    </dependency>

    <!-- Spring and Transactions -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring-framework.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${spring-framework.version}</version>
    </dependency>

    <!-- Spring Security -->
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>${spring.security.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>${spring.security.version}</version>
    </dependency>

    <!-- Spring ORM support -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>${spring-framework.version}</version>
    </dependency>

    <!-- Logging with SLF4J & LogBack -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${slf4j.version}</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>${logback.version}</version>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>commons-beanutils</groupId>
        <artifactId>commons-beanutils</artifactId>
        <version>1.9.2</version>
    </dependency>

    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.1.1</version>
    </dependency>

    <!-- Hibernate -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>${hibernate.version}</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>${hibernate.version}</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-c3p0</artifactId>
        <version>${hibernate.version}</version>
        <scope>provided</scope>
    </dependency>

    <!-- Test Artifacts -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${spring-framework.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>1.4</version>
    </dependency>

    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.3</version>
    </dependency>

    <dependency>
        <groupId>com.mchange</groupId>
        <artifactId>c3p0</artifactId>
        <version>0.9.5.2</version>
    </dependency>

    <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>20041127.091804</version>
    </dependency>

    <!-- Memory Leak Preventer -->
    <dependency>
      <groupId>se.jiderhamn.classloader-leak-prevention</groupId>
      <artifactId>classloader-leak-prevention-servlet</artifactId>
      <version>2.6.1</version>
    </dependency>

    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.2.2</version>
    </dependency>

    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.4</version>
    </dependency>

    <dependency>
        <groupId>org.apache.ant</groupId>
        <artifactId>ant</artifactId>
        <version>1.8.2</version>
    </dependency>

</dependencies>

<build>

    <plugins>

        <plugin>

            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat8-maven-plugin</artifactId>
            <!-- <version>2.2</version> -->
            <version>3.0-r1756463</version>
            <configuration>
                <port>8010</port>
            </configuration>

        </plugin>

    </plugins>

</build>

这是我的index.jsp

<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>CRM</title>

    </head>

    <jsp:include page="maincontent/loader.jsp"></jsp:include>

    <body style="overflow-x:hidden"  onload="window.close();">
        <div id="headerDiv" class="container-fluid">
            <jsp:include page="maincontent/mainheader.jsp"></jsp:include>
        </div>
        <div id="mainDiv" class="container">
            <jsp:include page="login/loginform.jsp"></jsp:include>
        </div>
        <div id="navDiv"></div>
        <div class="maincontentdiv container-fluid tab-content" id="maincontentDiv">
            <div class="tab-pane fade in" id="homeDiv"></div>
            <div class="tab-pane fade in" id="polInqDiv"></div>
            <div class="tab-pane fade in" id="clmInqDiv"></div>
            <div class="tab-pane fade in" id="openClmDiv"></div>
            <div class="tab-pane fade in" id="openClntPrflDiv"></div>
            <div class="tab-pane fade in" id="draftClmDiv"></div>
        </div>
        <div id="messageDialogDiv" title="">
            <br/><br/>
            <span id="messageIcon" style="float:left; margin:-3px 10px 0px 0;width: 20px;height:20px;"></span>
            <div id="messageDiv"></div>
            <br/>
        </div>
        <div id="onloadDiv">
        </div>
    </body>

    <script type="text/javascript">
        var indexselected = "HOME";
    </script>

</html>

1 个答案:

答案 0 :(得分:0)

以下内容应提供范围:

<dependency>
    <groupId>javax.servlet.jsp</groupId>
    <artifactId>jsp-api</artifactId>
    <version>${jsp.version}</version>
    <scope>provided</scope>
</dependency>

我希望这可以解决您的问题。