HTTP Status 500 - java.lang.NoClassDefFoundError: Could not initialize class org.apache.jasper.el.ELContextImpl [duplicate]

只愿长相守 提交于 2019-12-08 10:04:30

问题


When I try to browse "localhost:8080" on myeclipse, I get the following error:

type Exception report

message java.lang.NoClassDefFoundError: Could not initialize class org.apache.jasper.el.ELContextImpl

description The server encountered an internal error that prevented it from fulfilling this request.

exception 

javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class org.apache.jasper.el.ELContextImpl
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:343)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)


root cause 

java.lang.NoClassDefFoundError: Could not initialize class org.apache.jasper.el.ELContextImpl
    org.apache.jasper.compiler.Validator$ValidateVisitor.prepareExpression(Validator.java:1568)
    org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:747)
    org.apache.jasper.compiler.Node$ELExpression.accept(Node.java:954)
    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.Validator.validateExDirectives(Validator.java:1795)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:217)
    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)

回答1:


Are you trying to run a Web app on Jetty server? The error NoClassDefFoundError means you do not have the jar file required to run that code.

Here is the stackoverflow question on the same issue.

org.apache.jasper.el.ELContextImpl cannot be cast to org.apache.jasper.runtime.ELContextImpl

If you are using the Eclipse IDE, I recommend you to download the Eclipse Jetty plugin

https://code.google.com/p/run-jetty-run/

or in your eclipse under help -> Market place -> enter 'jetty' or 'jetty plugin' then download run-jetty-run plugin




回答2:


In eclipse when there is a HTTP Status 500 - java.lang.NoClassDefFoundError in developing web application whether tomcat or jetty etc make sure to put the needed .jar files in the lib folder under the WEB-INF folder (/WEB-INF/lib) to solve the error




回答3:


I had the similar issue while trying to access localhost:8080. This is happening because tomcat is able to detect more than 1 copy of jasper.jar jsp-api,jasper-el.

The issue is due to conflicting jars.

Please remove the above jars from

  1. java/jdk(version)/jre/lib/ext
  2. Also remove the above jars from your web application lib directory.

Restart the tomcat and it will work fine.



来源:https://stackoverflow.com/questions/16624487/http-status-500-java-lang-noclassdeffounderror-could-not-initialize-class-org

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!