无线&移动互联网技术研发

换位思考·····
posts - 19, comments - 53, trackbacks - 0, articles - 283
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

Tomcat JspFactory的异常的原因及解决办法

Posted on 2010-12-14 17:32 Gavin.lee 阅读(1255) 评论(1)  编辑  收藏 所属分类: 经验&常识

摘:http://depravedangel.javaeye.com/blog/421663
The method getJspApplicationContext(ServletContext) is undefined for the type 
 
JspFactory的异常的原因及解决办法原因:
     服务器环境Jboss,Java程由Tomcat5.5工程目录直接拷贝,由于WEB-INF/lib下存在jsp-api.jar、servlet-api.jar,与Jboss自带的jar包冲突造成。
 
 解决办法:
     删除WEB工程Lib目录中的jsp-api.jar、servlet-api.jar,重新启动Jboss服务问题解决。 
 
标记:
     在创建工程时,jsp-api.jar、servlet-api.jar这两个jar包都无需手工加入到web工程中,tomcat与jboss都已包含。
 
今天运行以前的一个老项目,不成想抛出下面的异常
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:423)
        org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
        org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
        org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
        org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
上网搜,发现不少人有这个问题,但都没有解决办法。后来想到可能和tomcat6有关,因为我在工程的lib中添加了很多包(一堆什么Spring
依赖),所以把他们一删JSP就不抛异常了。我估计是,工程中和tomcat6 lib中重复的包在加载时是先被加载(也就是tomcat6中相同的包没
有被加载),而工程中的包版本要比tomcat6中的低,造成上面的异常。我对照着tomcat中包,发现工程中出现诸如catalina.jar、jsp-api.jar
、servlet-api.jar等这样的重复包,把它们从工程中删了就应该行了(对于上面的异常,原因应该是包jsp-api.jar)。看来不是什么包都可以一股脑往工程里加啊。


请关注@我的新浪微博


评论

# re: Tomcat JspFactory的异常的原因及解决办法 没有重复的包  回复  更多评论   

2014-04-02 16:03 by
An error occurred at line: 22 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:592)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:326)
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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:438)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:421)
at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:342)
at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:286)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
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.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)

只有注册用户登录后才能发表评论。


网站导航: