javax.servlet.ServletException:java.lang.NoClassDefFoundError:JspException

时间:2013-10-21 20:10:34

标签: java java-ee tomcat servlets

我有以下代码:

RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(address);
dispatcher.forward(req,res);

此代码的第二行在标题中产生错误。这是我的图书馆:

enter image description here

这是我的pom.xml:

<dependencies>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-servlet-api</artifactId>
        <version>7.0.39</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-api</artifactId>
        <version>7.0.39</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-catalina</artifactId>
        <version>7.0.39</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-el-api</artifactId>
        <version>7.0.30</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-jasper-el</artifactId>
        <version>7.0.30</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.ibm.db2</groupId>
        <artifactId>db2jcc</artifactId>
        <version>3.59.81</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.ibm.db2</groupId>
        <artifactId>db2jcc_license_cu</artifactId>
        <version>3.59.81</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.ibm.db2</groupId>
        <artifactId>db2jcc_license_cisuz</artifactId>
        <version>3.59.81</version>
        <scope>provided</scope>
    </dependency>

</dependencies>

这是堆栈跟踪:

java.lang.NoClassDefFoundError: JspException
    java.lang.Class.getDeclaredMethods0(Native Method)
    java.lang.Class.privateGetDeclaredMethods(Class.java:2531)
    java.lang.Class.privateGetPublicMethods(Class.java:2651)
    java.lang.Class.getMethods(Class.java:1467)
    java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1280)
    java.beans.Introspector.getTargetMethodInfo(Introspector.java:1141)
    java.beans.Introspector.getBeanInfo(Introspector.java:416)
    java.beans.Introspector.getBeanInfo(Introspector.java:163)
    org.apache.jasper.compiler.Generator$TagHandlerInfo.<init>(Generator.java:3957)
    org.apache.jasper.compiler.Generator$GenerateVisitor.getTagHandlerInfo(Generator.java:2212)
    org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1643)
    org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1539)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
    org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
    org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1773)
    org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1539)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
    org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
    org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
    org.apache.jasper.compiler.Node$Root.accept(Node.java:475)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
    org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
    org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2452)
    org.apache.jasper.compiler.Node$IncludeDirective.accept(Node.java:639)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
    org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
    org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
    org.apache.jasper.compiler.Node$Root.accept(Node.java:475)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
    org.apache.jasper.compiler.Generator.generate(Generator.java:3503)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:250)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    MT_Servlet.gotoPage(MT_Servlet.java:160)
    MT_TasEntryServlet.doPost(MT_TasEntryServlet.java:1562)
    MT_TasEntryServlet.doGet(MT_TasEntryServlet.java:45)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    MT_Servlet.gotoPage(MT_Servlet.java:160)
    MT_TBLServletController.doPost(MT_TBLServletController.java:217)
    MT_TBLServletController.doGet(MT_TBLServletController.java:31)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

有没有人看到这个问题?

2 个答案:

答案 0 :(得分:2)

javax.servlet.JspException包含在jsp-api.jar中(您还可以找到包含jars here)。有关更多信息,请查看this answer

答案 1 :(得分:0)

将jsp-api.jar添加到tomcat lib目录的类路径中。右键单击你的project-properties-buildpath-add external jars-转到tomcat lib目录并选择jsp-api.jar。 然后刷新您的项目。它现在应该删除此异常。