2015-10-01 80 views
1

我創建的Servlet這個原型:http://maciejwalkowiak.github.io/servlet3-maven-archetype/的Tomcat無法編譯類JSP Servlet 3.0中

mvn archetype:generate \ 
    -DarchetypeGroupId=pl.maciejwalkowiak \ 
    -DarchetypeArtifactId=servlet3-webapp-archetype \ 
    -DarchetypeVersion=1.0.1 

然後我添加的index.jsp到的src/main/webapp目錄

<%@ page language="java" contentType="text/html; charset=UTF-8" 
    pageEncoding="UTF-8"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>Insert title here</title> 
</head> 
<body> 
<h1>hello, world</h1> 
</body> 
</html> 

時我跑mvn tomcat7:run和開放http://127.0.0.1/mycontext/index.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.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:469) 
    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:722) 

有什麼問題?

更新

我使用java8但我已經在我的行家以下Maven編譯配置:

 <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.3.2</version> 
      <configuration> 
       <source>1.7</source> 
       <target>1.7</target> 
      </configuration> 
     </plugin> 
+0

嘗試清理您的項目。 –

+0

mvn乾淨,但沒有解決 –

回答

1

您正在使用哪個版本的JDK?如果它是8,你將不得不更新Tomcat到8。如果不是這種情況,您應該嘗試進入「項目」菜單並從中選擇「清潔...」。然後嘗試通過從右鍵單擊菜單中選擇這些選項來清除服務器和服務器工作文件夾。

+0

看到我更新的問題。我正在使用maven-compiler插件來使用java 7 –

+0

您是否也嘗試清除它? – Aurasphere

+0

是的,但它不起作用。 –

2

你應該仔細檢查你的Tomcat版本。 Tomcat 7.0.32包含一個與Java 8不完全兼容的jar,所以升級Tomcat版本可能會有所幫助。看看this

+0

或者,您也可以嘗試單獨升級到ecj-4.2.2.jar。 – User2709