jsp The method getJspApplicationContext(ServletContext) is undefined for the typ

The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory的解决方法:

环境:Tomcat6,  IDE Myeclipse

 

Myeclipse控制台显示信息:

严重: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 23 in the generated java file
The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory

Stacktrace:
 at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
 at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
 at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
 at org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
 at org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
 at org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
 at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
 at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
 at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
 at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
 at java.lang.Thread.run(Thread.java:619)

 

前台页面显示:

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 23 in the generated java file
The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory

Stacktrace:
	org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
	org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
	org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

 

因为项目中有像jsp-api.jar servlet-api.jar(主要是这个包引起的)跟tomcat6的lib中同样的包,
但版本比tomcat6的版本要低,在运行的时候,因为会优先加载项目中的包,
所以产生了错误,把项目中和tomcat相同的包删除(必须删除,如果替换还会产生其他的错误),
问题就可以解决了。

你可能感兴趣的:(jsp The method getJspApplicationContext(ServletContext) is undefined for the typ)