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

最近又开始看jsp,那时候用的tomcat还是5的版本,我现在自己下的用的是tomcat6,在运行随书光盘的例子的时候,报了这样的错误:
type Exception report

message 

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: 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:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
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)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.24 logs.
Apache Tomcat/6.0.24

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

实际通过这个问题,则可以明白,在布署jsp网站(在tomcat上)的时候,项目中的jar包不能有和tomcat的lib中相同的包(自己包的版本比 tomcat低或相同),否则会因为先加载自己项目中的包而导致程序错误。所以在有相包的情况的时候,将自己的包给删掉,就不会出现问题了。
posted on 2010-05-20 15:39  小顾问  阅读(23044)  评论(0编辑  收藏  举报