rt.jar servlet-api.jar我正在回答这个问题 ,并建议将其关闭,因为这是一个简单的错误",但有些读者可能会发现查看分辨率的实际值很有用.I've been tasked with migrating a site from one institution to another. As part of the process we are attempting to update the versions the site uses.Initially I was asked to use Java 8 with Tomcat 5.5 (on Linux), which led to issues. I have since tried to deploy the webapps to Tomcat 9 with Java 8. Some of the webapps appear to run fine (and resolve the issues I was having with Tomcat5). However, the main app throws a JasperException when I go to the index.jsp- the same web app deployed to Tomcat 5.5 loads without issue.org.apache.jasper.JasperException: Unable to compile class for JSP:An error occurred at line: [15] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]The type index_jsp must implement the inherited abstract method JspSourceImports.getPackageImports()An error occurred at line: [15] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]The type index_jsp must implement the inherited abstract method JspSourceImports.getClassImports()An error occurred at line: [15] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]The type index_jsp must implement the inherited abstract method JspSourceDependent.getDependants()An error occurred at line: [22] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]The type Map is not generic; it cannot be parameterized with arguments <String, Long>An error occurred at line: [24] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]The type Set is not generic; it cannot be parameterized with arguments <String>An error occurred at line: [26] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]The type Set is not generic; it cannot be parameterized with arguments <String>An error occurred at line: [29] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]_jspx_imports_packages cannot be resolved to a variableAn error occurred at line: [29] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]The type HashSet is not generic; it cannot be parameterized with arguments <>An error occurred at line: [30] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]_jspx_imports_packages cannot be resolvedAn error occurred at line: [31] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]_jspx_imports_packages cannot be resolvedAn error occurred at line: [32] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]_jspx_imports_packages cannot be resolvedAn error occurred at line: [33] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]_jspx_imports_classes cannot be resolved to a variableAn error occurred at line: [39] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]The type Map is not generic; it cannot be parameterized with arguments <String, Long>An error occurred at line: [40] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]_jspx_dependants cannot be resolved to a variableAn error occurred at line: [43] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]The type Set is not generic; it cannot be parameterized with arguments <String>An error occurred at line: [44] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]_jspx_imports_packages cannot be resolved to a variableAn error occurred at line: [47] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]The type Set is not generic; it cannot be parameterized with arguments <String>An error occurred at line: [48] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]_jspx_imports_classes cannot be resolved to a variableStacktrace: org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:213) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:458) org.apache.jasper.compiler.Compiler.compile(Compiler.java:389) org.apache.jasper.compiler.Compiler.compile(Compiler.java:361) org.apache.jasper.compiler.Compiler.compile(Compiler.java:345) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:603) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) edu.purdue.cybercenter.ionomics.servlet.PiiMS.doGet(PiiMS.java:83) javax.servlet.http.HttpServlet.service(HttpServlet.java:634) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)Most of the similar issues I have found have suggested this would be related to the jar files and possibly some sort of conflict. However, the lib structure for tomcat 9 is different to tomcat5 and I'm not sure which jars could be causing this. I've also tried changing the index.jsp into a simpler (HelloWorld) form - removing any code, with the same Exception thrown.Has anyone experienced a similar problem and/or have any advice?Thanks. 解决方案 In this particular case, it looks like the problem was a number of libraries in the application's WEB-INF/lib directory that really needed to be removed, including:rt.jarservlet-api.jarI'm answering this question and recommending that it be closed as it was a "simple mistake", but some readers may find it useful to see what the resolution actually was. 这篇关于使用Tomcat 9时出现Jasper异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-18 18:36