Java tomcat编译jsp失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19686213/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
tomcat fail to compile jsp
提问by user2130951
I can't seem to get tomcat to compile the jsp files it should serve. It will run .war files and servlets perfectly fine. But will fail on any jsp page. I am getting the impression it does not find the regular java includes.
我似乎无法让 tomcat 编译它应该提供的 jsp 文件。它将完美地运行 .war 文件和 servlet。但是在任何jsp页面上都会失败。我得到的印象是它没有找到常规的 java 包含。
I am trying with this file (or any other jsp test file included)
我正在尝试使用此文件(或包含的任何其他 jsp 测试文件)
<%@ page language="java" import="java.util.*" errorPage="" %>
<html>
<body>
Current Date time: <%=new java.util.Date()%>
</body>
</html>
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.JasperException: Unable to compile class for JSP:
An error occurred at line: 1 in the generated java file
The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:468)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.35 logs.
注意 Apache Tomcat/7.0.35 日志中提供了根本原因的完整堆栈跟踪。
log:
日志:
Oct 30, 2013 4:56:12 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path [/tomcat-demo] threw exception [Unable to compile class for JSP:
An error occurred at line: 1 in the generated java file
The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files
Stacktrace:] with root cause
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 1 in the generated java file
The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files
Stacktrace:
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:468)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:200)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:724)
This is the ps axf for this process.
9277 ? Sl 0:23 /usr/lib/jvm/java-8-oracle/bin/java -
Djava.util.logging.config.file=/var/lib/tomcat7/conf/logging.properties -
Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC -Dbuild.compiler=javac -
Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -
Djava.endorsed.dirs=/usr/share/tomcat7/endorsed -classpath
/usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar -
Dcatalina.base=/var/lib/tomcat7 -Dcatalina.home=/usr/share/tomcat7 -
Djava.io.tmpdir=/tmp/tomcat7-tomcat7-tmp org.apache.catalina.startup.Bootstrap start
采纳答案by flob
Tomcat 7.0.35 and java 8 don't play well together, so use a recent version of Tomcat and the ECJ module, that bug is fixed by now.
Tomcat 7.0.35 和 java 8 不能很好地配合使用,因此请使用最新版本的 Tomcat 和 ECJ 模块,该错误现已修复。
Tomcat Version 7.0.50 and ECJ 4.3.1 (or newer) should work. See JBoss Ticketas mentioned in the comments by @AtliB.
Tomcat 版本 7.0.50 和 ECJ 4.3.1(或更新版本)应该可以工作。请参阅@AtliB 评论中提到的JBoss 票证。
回答by Allen
I was just struggling with a very similar problem. For me it turned out that I was running Tomcat with a "tomcat7" user, but "root" was the owner of many of the tomcat files and directories. After I changed "tomcat7" to own everything in the tomcat directory (recursively) it started working for me.
我只是在一个非常相似的问题上挣扎。对我来说,结果是我使用“tomcat7”用户运行 Tomcat,但“root”是许多 tomcat 文件和目录的所有者。在我将“tomcat7”更改为拥有 tomcat 目录中的所有内容(递归)后,它开始为我工作。
回答by Ibanezje
For me it was the answer @AtliB provided. The problem is in the jar compiler. I installed Tomcat by dropping one folder in another. Same filenames were overwritten, but not the ones with version numers :(. So I had Multiple ecj-x.x files. And Tomcat just loads the first one it sees. Deleting the old ones left me ecj-4.4.jar, which works like a charm on java 8!
对我来说,这是@AtliB 提供的答案。问题出在 jar 编译器中。我通过将一个文件夹放入另一个文件夹来安装 Tomcat。相同的文件名被覆盖,但没有版本号的文件名:(。所以我有多个 ecj-xx 文件。Tomcat 只加载它看到的第一个文件。删除旧文件后我留下了 ecj-4.4.jar,它的工作原理类似于Java 8 的魅力!