2013-10-30 184 views
4

我似乎無法讓tomcat編譯它應該服務的jsp文件。它將運行.war文件和servlet完美無瑕。但是會在任何jsp頁面上失敗。我得到的印象是它沒有發現常規的Java包含。tomcat無法編譯jsp

我與這個文件試圖(或包括任何其他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 
+0

您是否需要導入(如果您正在使用列表(或)arraylist等)? – kosa

+0

檢查日誌文件夾中的日誌文件並查看任何線索 – kosa

+0

添加了有關測試文件的信息和部分catalina.out。你需要任何其他的日誌信息嗎? – user2130951

回答

9

的Tomcat 7.0.35和Java 8千萬不能很好地在一起玩,所以使用最新版本的Tomcat和ECJ模塊,該缺陷是由現在固定。

Tomcat版本7.0.50和ECJ 4.3.1(或更新)應該可以工作。請參閱@AtliB的評論中提及的JBoss Ticket

+0

這不提供答案這個問題。要批評或要求作者澄清,請在其帖子下方留言。 –

+0

答案是'使用最新版本的Tomcat,你遇到了一個現在已經修復的錯誤。'......不需要澄清。 – flob

+0

即使使用tomcat 7.0.52,在ubuntu 12.04上仍然使用ubuntu 14.04的軟件包,我仍然遇到這個錯誤。 – BrunoJCM

1

我只是在與一個非常類似的問題掙扎。對我來說,事實證明我是用「tomcat7」用戶運行Tomcat的,但「root」是許多tomcat文件和目錄的擁有者。在將「tomcat7」更改爲擁有tomcat目錄中的所有內容(遞歸)之後,它開始爲我工作。

0

對我而言,這是@AtliB提供的答案。 問題出在jar編譯器。 我通過在另一個文件夾中放置一個文件夾來安裝Tomcat。相同的文件名被覆蓋,但不是版本numers :(。所以我有多個ecj-xx文件。而Tomcat只是加載它看到的第一個。 刪除舊的留給我ecj-4.4.jar,它的工作原理Java 8的魅力!