Jsp servlet异常 [英] Jsp servlet exception

查看:126
本文介绍了Jsp servlet异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我也看到了一些类似的答案,但我觉得我的情况有所不同。我正在开发一个迄今为止运行良好的Spring MVC应用程序,那就是我在项目中包含hadoop api,当我包含hadoop时,此异常开始发生,当我尝试打开之前工作的初始仪表板页面时:

  java.lang.AbstractMethodError:javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax / servlet / 
ServletContext;)Ljavax / servlet / JSP / JspApplicationContext;
org.apache.jsp.ServerInfo_jsp._jspInit(ServerInfo_jsp.java:63)
org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52)
org.apache。 jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:158)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet。 serviceJspFile(JspServlet.java:336)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:9



<

 <依赖项> 
< groupId> org.apache这是我的hadoop依赖关系的样子。 .hadoop< / groupId>
< artifactId> hadoop-client< / artifactId>
< version> 0.23.1-mr1-cdh4.0.0b2< / version>
<依赖关系>
< d ependency>
< groupId> org.apache.hadoop< / groupId>
< artifactId> hadoop-core< / artifactId>
< version> 0.23.1-mr1-cdh4.0.0b2< / version>
<排除项>
<排除>
< groupId> org.mortbay.jetty< / groupId>
< artifactId> jetty< / artifactId>
< /排除>
<排除>
< groupId> javax.servlet< / groupId>
< artifactId> servlet-api< / artifactId>
< /排除>
< /排除>
< /依赖关系>

一旦我将它添加到我的应用程序中,它就不再可用了,并且自然没有这些依赖性,运行非常流畅。我在这里错过了什么?

解决方案

我认为你的问题在于,hadoop包含了即将到来的servlet API版本在类路径中的正确的servlet API之前。 Hadoop对Jetty有依赖性,jetty会尝试包含一个servlet API。

我有一个项目,它的设置非常类似Spring MVC和Hadoop。对于hadoop依赖,我有以下排除。请注意,这可能会有所不同,具体取决于您的hadoop分布,我正在使用cloudera的。由于您使用的servlet容器通常会附带自己的javax.servlet依赖项,因此您的排除项目需要解决这个问题。我只用Jetty测试了以下配置:

 < dependency> 
< groupId> org.apache.hadoop< / groupId>
< artifactId> hadoop-core< / artifactId>
< version> $ {hadoop.version}< / version>
<排除项>

<排除>
< groupId> org.mortbay.jetty< / groupId>
< artifactId> jetty< / artifactId>
< /排除>
<排除>
< groupId> org.mortbay.jetty< / groupId>
< artifactId> jetty-util< / artifactId>
< /排除>
<排除>
< groupId> org.mortbay.jetty< / groupId>
< artifactId> jsp-2.1< / artifactId>
< /排除>
<排除>
< groupId> org.mortbay.jetty< / groupId>
< artifactId> jsp-api-2.1< / artifactId>
< /排除>
<排除>
< groupId> org.mortbay.jetty< / groupId>
< artifactId> servlet-api-2.1< / artifactId>
< /排除>
<排除>
< groupId> javax.servlet< / groupId>
< artifactId> servlet-api< / artifactId>
< /排除>
<排除>
< groupId> javax.servlet.jsp< / groupId>
< artifactId> jsp-api< / artifactId>
< /排除>
<排除>
< groupId> tomcat< / groupId>
< artifactId> jasper-compiler< / artifactId>
< /排除>
<排除>
< groupId> tomcat< / groupId>
< artifactId> jasper-runtime< / artifactId>
< /排除>
<! - 为简洁起见剪切了其他排除项目 - >


I've seen some similar answer to this question perhaps but I feel my situation is different. I'm developing a spring MVC app working great so far, that is I included hadoop api in my project, when I included hadoop this exception started happening when I am trying to open the initial dashboard page which worked previously :

java.lang.AbstractMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ 
ServletContext;)Ljavax/servlet/jsp/JspApplicationContext;
 org.apache.jsp.ServerInfo_jsp._jspInit(ServerInfo_jsp.java:63)
 org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52)
 org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:158)
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
 org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:9

Here is how my hadoop dependency looks like :

<dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-client</artifactId>
            <version>0.23.1-mr1-cdh4.0.0b2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-core</artifactId>
            <version>0.23.1-mr1-cdh4.0.0b2</version>
            <exclusions>
                <exclusion>
                    <groupId>org.mortbay.jetty</groupId>
                    <artifactId>jetty</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.servlet</groupId>
                    <artifactId>servlet-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

Once I add this to my app it's no longer usable and naturally without these dependecies things run very smooth. What am I missing here?

解决方案

I think that your problem is that hadoop is including a version of the servlet API which is coming before the "correct" servlet API in the classpath. Hadoop has dependencies on Jetty, and jetty will in turn try to include a servlet API.

I have a project with a very similar setup, Spring MVC and Hadoop. I have the below exclusions for the hadoop dependency. Note that this might vary slightly depending on your hadoop distribution, I am using cloudera's. Since the servlet container you are using will usually ship with its own javax.servlet dependency, your exclusion needs to catch this case. I have only tested the below configuration with Jetty:

           <dependency>     
              <groupId>org.apache.hadoop</groupId>
              <artifactId>hadoop-core</artifactId>
              <version>${hadoop.version}</version>
           <exclusions>

          <exclusion>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jetty</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jetty-util</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jsp-2.1</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jsp-api-2.1</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>servlet-api-2.1</artifactId>
            </exclusion>
            <exclusion>
                <groupId>javax.servlet</groupId>
                <artifactId>servlet-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>javax.servlet.jsp</groupId>
                <artifactId>jsp-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>tomcat</groupId>
                <artifactId>jasper-compiler</artifactId>
            </exclusion>
            <exclusion>
                <groupId>tomcat</groupId>
                <artifactId>jasper-runtime</artifactId>
            </exclusion>
            <!-- other exclusions snipped for brevity -->

这篇关于Jsp servlet异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆