【记录01】idea+maven+Servlet+JSP org.apache.jasper.JasperException: Unable to compile class for JSP:

【记录01】idea+maven+Servlet+JSP org.apache.jasper.JasperException: Unable to compile class for JSP:

注意

当第一次用idea配置maven写Servlet+JSP写HelloWorld代码时,要注意maven默认启用的Tomcat 6点多的版本,而工程需要tomcat 7以上版本。出现如下报错,可以考虑是不是这个问题

1. org.apache.jasper.JasperException: 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:
........
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.29 logs.

2. javax.servlet.ServletException: Class cn.trajectories.servlet.MyServlet is not a Servlet

这个报错还可能是Servlet和Jsp的jar包冲突,加上域限制。可另外搜索这种解决方法。

description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Class cn.trajectories.servlet.MyServlet is not a Servlet
......
root cause
java.lang.ClassCastException: class cn.trajectories.servlet.MyServlet cannot be cast to class javax.servlet.Servlet (cn.trajectories.servlet.MyServlet is in unnamed module of loader org.apache.catalina.loader.WebappClassLoader @3b5c665c; javax.servlet.Servlet is in unnamed module of loader org.codehaus.plexus.classworlds.realm.ClassRealm @7aa9e414)
.....
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.29 logs.

3. The requested resource (Servlet MyServlet is not available) is not available.

type Status report
message Servlet MyServlet is not available
description The requested resource (Servlet MyServlet is not available) is not available.

解决方法

把 maven 启动项目的默认tomcat6更换为tomcat7或更高版本

可参考:

  1. maven更改启动后项目默认的tomcat版本
  2. maven 启动项目默认tomcat6更换为tomcat7或其他版本
# Java  IDEA  Maven 

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×