解决Jsp运行org.apache.jasper.JasperException: Unable to compile class for JSP:问题

初学Maven就遇到困难了!!!在b站跟着视频开始接触maven来创建一个webapp项目,在jsp跳转的时候遇到一个bug,身边也没大佬带,只能自己慢慢摸索,在Maven项目中出现了报org.apache.jasper.JasperException: Unable to compile class for JSP:的问题,在网上查了很多方法来尝试解决,但天资愚钝无法理解大佬的跳转思维,后面某论坛看到解决放方案。

链接:https://blog.csdn.net/u011781521/article/details/53713162

一、问题描述

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 <?xml version="1.0" encoding="UTF-8"?>
 2
 3 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 5   <modelVersion>4.0.0</modelVersion>
 6
 7   <groupId>com.itheima</groupId>
 8   <artifactId>maven_java</artifactId>
 9   <version>1.0-SNAPSHOT</version>
10   <packaging>war</packaging>
11
12   <name>maven_java Maven Webapp</name>
13   <!-- FIXME change it to the project‘s website -->
14   <url>http://www.example.com</url>
15
16   <properties>
17     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18     <maven.compiler.source>1.7</maven.compiler.source>
19     <maven.compiler.target>1.7</maven.compiler.target>
20   </properties>
21
22   <dependencies>
23     <dependency>
24       <groupId>junit</groupId>
25       <artifactId>junit</artifactId>
26       <version>4.11</version>
27       <scope>test</scope>
28     </dependency>
29
30     <dependency>
31       <groupId>javax.servlet</groupId>
32       <artifactId>servlet-api</artifactId>
33       <version>2.5</version>
34       <scope>provided</scope>
35     </dependency>
36
37     <!-- https://mvnrepository.com/artifact/javax.servlet.jsp/jsp-api -->
38     <dependency>
39       <groupId>javax.servlet.jsp</groupId>
40       <artifactId>jsp-api</artifactId>
41       <version>2.1</version>
42       <scope>provided</scope>
43     </dependency>
44
45   </dependencies>
46
47   <build>
48     <finalName>maven_java</finalName>
49     <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
50       <plugins>
51         <plugin>
52           <artifactId>maven-clean-plugin</artifactId>
53           <version>3.1.0</version>
54         </plugin>
55         <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
56         <plugin>
57           <artifactId>maven-resources-plugin</artifactId>
58           <version>3.0.2</version>
59         </plugin>
60         <plugin>
61           <artifactId>maven-compiler-plugin</artifactId>
62           <version>3.8.0</version>
63         </plugin>
64         <plugin>
65           <artifactId>maven-surefire-plugin</artifactId>
66           <version>2.22.1</version>
67         </plugin>
68         <plugin>
69           <artifactId>maven-war-plugin</artifactId>
70           <version>3.2.2</version>
71         </plugin>
72         <plugin>
73           <artifactId>maven-install-plugin</artifactId>
74           <version>2.5.2</version>
75         </plugin>
76         <plugin>
77           <artifactId>maven-deploy-plugin</artifactId>
78           <version>2.8.2</version>
79         </plugin>
80         <plugin>
81           <groupId>org.apache.tomcat.maven</groupId>
82           <artifactId>tomcat7-maven-plugin</artifactId>
83           <version>2.2</version>
84         </plugin>
85       </plugins>
86     </pluginManagement>
87   </build>
88 </project>

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

二、解决方法

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

把它改为: tomcat7:run 就行了,就不会报错了

原文地址:https://www.cnblogs.com/junxiaobai/p/10915504.html

时间: 2024-11-09 05:56:44

解决Jsp运行org.apache.jasper.JasperException: Unable to compile class for JSP:问题的相关文章

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

1.错误描述 Count:858org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 12 in the jsp file: /resource/pages/storageTankQuery/storageTankInfo/storageTankInfo.jsp basePath cannot be resolved to a variable 9: // 璺

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

部署war时,遇到下面异常: exception org.apache.jasper.JasperException: Unable to compile class for JSP org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:604) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328

Jsp抛出异常org.apache.jasper.JasperException

在eclipse中部署项目web有时候访问jsp会抛出以下类似的异常信息 org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp 部署web项目,如果抛出此异常.请保证 standard.jar与jstl.jar 两个jar包是否 在部署的项目中存在,如果不存在,请把 这两个包加入 /WEB-INF/lib 中.然后保证jsp中引用的版本地址 和 此版本地址是一致的: <%@ taglib uri=

maven用框架编写网页运行出现HTTP Status 500 - Unable to compile class for JSP

利用maven整合框架的时候,通过浏览器访问时,如果出现  HTTP 500-Unable to compile class for JSP 的错误,应该怎么解决呢? 之前在网上看了好多人的解决方案.都不合适我,最后我发现在一个maven视频里面看到的.maven里的pom.xml把tomcat改成只读就好了,因为导入的jar和tomact自带的有冲突 这样改就可以正常的访问所写的项目了 我在整理几项其余的HTTP 500-Unable to compile class for JSP 的错误

Unable to compile class for JSP 错误的解决过程。

刚配置好Tomcat.启动项目没问题.然后一访问就报错了. ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 2012-8-18 19:17:40 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet jsp threw exception org.apac

Maven项目不能编译jsp解决方法:Unable to compile class for JSP

一.问题描述: 先交代开发环境,JDK是1.8的,IDE是eclipse 4.7,web服务器是Tomcat 9.0,maven是3.5.0,搭建好环境后输入命令tomcat:run,然后就报org.apache.jasper.JasperException: Unable to compile class for JSP错误. 二.分析问题: (1)不能编译应该是没有导入servlet-api.jsp-api包的原因,然后就在pom文件中加上servlet-api.jsp-api包,为了防止包

JAVA Drp项目实战—— Unable to compile class for JSP 一波三折

交代下背景,电脑系统是64位的,用的是64位的Tomcat,安装是32位的Myeclipse10,java环境也是32位的,Tomcat在开始启动时会报这样一个错误,"Can't load IA 64-bit .dll on a AMD32-bit platform",但是不耽误使用,最近在敲Drp项目中用到了底层接口的几个方法,这个错误导致项目不能正常运行了,所以就将64位的Tomcat换成了与java环境一样的32位的Tomcat,上面的问题就顺利解决了,于是继续自己的开发,但是当

Message Unable to compile class for JSP

使用 UniEAPWorkshop_5.0运行4.6 的代码,流程新建时出现的错误 JDK 使用C:\Program Files (x86)\Java\jdk1.7.0_80 tomcat使用 apache-tomcat-7.0.91   改成apache-tomcat-6.0.41 解决! HTTP Status 500 – Internal Server Error ---------------------------------------------------------------

jsp调用javabean出现错误HTTP Status 500 - Unable to compile class for JSP

HTTP Status 500 - Unable to compile class for JSP: type Exception report message Unable to compile class for JSP: description The server encountered an internal error that prevented it from fulfilling this request. exception org.apache.jasper.JasperE