启动tomcat卡在starting状态,然后访问页面就报错:org.apache.jasper.JasperException: Unable to compile class for JSP

一、问题描述


eclipse通过maven插件创建一个WEB项目通过内嵌Tomcat加载项目,启动没问题,一访问页面就报错提示无法将jsp编译为class文件:


org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 1 in the generated java file
The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files

Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
    org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)




错误的原因为:tomcat6不支持jdk1.8版本


我pom.xml文件里明明配置的是Tomcat7啊!!  怎么是tomcat6运行去了。。。


  1. <project xmlns=“http://maven.apache.org/POM/4.0.0” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”  
  2.   xsi:schemaLocation=“http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd”>  
  3.   <modelVersion>4.0.0</modelVersion>  
  4.   <groupId>com.fendo.sse</groupId>  
  5.   <artifactId>com</artifactId>  
  6.   <packaging>war</packaging>  
  7.   <version>0.0.1-SNAPSHOT</version>  
  8.   <name>com Maven Webapp</name>  
  9.   <url>http://maven.apache.org</url>  
  10.   <dependencies>  
  11.     <dependency>  
  12.       <groupId>junit</groupId>  
  13.       <artifactId>junit</artifactId>  
  14.       <version>3.8.1</version>  
  15.       <scope>test</scope>  
  16.     </dependency>  
  17.       
  18.        <!– 加入ServletAPI –>  
  19.         <!– https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api –>  
  20.         <dependency>  
  21.             <groupId>javax.servlet</groupId>  
  22.             <artifactId>servlet-api</artifactId>  
  23.             <version>2.3</version>  
  24.             <scope>provided</scope>  
  25.         </dependency>  
  26.       
  27.   </dependencies>  
  28.   <build>  
  29.     <finalName>com</finalName>  
  30.     <plugins>  
  31.       <plugin>  
  32.                 <groupId>org.codehaus.mojo</groupId>  
  33.                 <artifactId>tomcat-maven-plugin</artifactId>  
  34.                 <version>1.1</version>  
  35.                 <configuration>  
  36.                     <port>8080</port>  
  37.                     <uriEncoding>UTF-8</uriEncoding>  
  38.                     <url>http://localhost:8080/manager/html</url>  
  39.                     <server>tomcat7</server>  
  40.                 </configuration>  
  41.             </plugin>  
  42.     </plugins>  
  43.   </build>  
  44. </project>  
<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.fendo.sse</groupId>
  <artifactId>com</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>com Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>

       <!-- 加入ServletAPI -->
        <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.3</version>
            <scope>provided</scope>
        </dependency>

  </dependencies>
  <build>
    <finalName>com</finalName>
    <plugins>
      <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <version>1.1</version>
                <configuration>
                    <port>8080</port>
                    <uriEncoding>UTF-8</uriEncoding>
                    <url>http://localhost:8080/manager/html</url>
                    <server>tomcat7</server>
                </configuration>
            </plugin>
    </plugins>
  </build>
</project>


注意: 如果你的版本是tomcat7-maven-plugin  2.0 的话,由于它不支持 jdk 1.8,所以把它换成 tomcat7-maven-plugin  2.2就行了。


二、解决方法


找了下发现原来是这里出了问题!!!




把它改为: tomcat7:run 就行了




在maven里自动下载tomcat-embed-core-7.0.47.jar会很慢,建议在网上下载该包,然后复制到仓库下

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值