tomcat无法编译jsp

时间:2013-10-30 14:51:35

标签: java jsp tomcat

我似乎无法让tomcat编译它应该服务的jsp文件。它将完美地运行.war文件和servlet。但是在任何jsp页面都会失败。我得到的印象是它没有找到常规的java包含。

我正在尝试使用此文件(或包含的任何其他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)

注意Apache Tomcat / 7.0.35日志中提供了根本原因的完整堆栈跟踪。

日志:

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

3 个答案:

答案 0 :(得分:10)

Tomcat 7.0.35和java 8不能很好地协同工作,所以使用最新版本的Tomcat和ECJ模块,这个bug现在已经修复。

Tomcat版本7.0.50和ECJ 4.3.1(或更新版本)应该可以使用。请参阅@AtliB评论中提到的JBoss Ticket

答案 1 :(得分:1)

我正在努力解决一个非常类似的问题。对我来说,事实证明我使用“tomcat7”用户运行Tomcat,但“root”是许多tomcat文件和目录的所有者。我将“tomcat7”更改为拥有tomcat目录中的所有内容(递归)后,它开始为我工作。

答案 2 :(得分:0)

对我来说,这是@AtliB提供的答案。 问题出在jar编译器中。 我通过在另一个中删除一个文件夹来安装Tomcat。相同的文件名被覆盖了,但不是那些带有版本号的文件名:(。所以我有多个ecj-x.x文件。而Tomcat只加载它看到的第一个文件名。 删除旧版本给我留下了ecj-4.4.jar,它就像java 8上的魅力一样!