Deploying a JSF webapp results in java.lang.ClassN

2020-02-06 07:09发布

I get an error, when I started my JavaServer Faces application. On the browser I get following error:

HTTP Status 500 - 

--------------------------------------------------------------------------------

type Exception report

message 

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

exception 

javax.servlet.ServletException: javax/servlet/jsp/jstl/core/Config
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:229)


root cause 

java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config
    org.apache.myfaces.view.jsp.JspViewDeclarationLanguage.buildView(JspViewDeclarationLanguage.java:91)
    org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:77)
    org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:199)


root cause 

java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
    org.apache.myfaces.view.jsp.JspViewDeclarationLanguage.buildView(JspViewDeclarationLanguage.java:91)
    org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:77)
    org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:199)


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

On my Eclipse IDE follwoing error:

    Nov 19, 2013 8:37:17 PM org.apache.catalina.startup.Catalina start
Information: Server startup in 2518 ms
Nov 19, 2013 8:37:18 PM org.apache.catalina.core.StandardWrapperValve invoke
Schwerwiegend: Servlet.service() for servlet [Faces Servlet] in context with path [/de.xxx.jsf.first] threw exception [javax/servlet/jsp/jstl/core/Config] with root cause
java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
    at org.apache.myfaces.view.jsp.JspViewDeclarationLanguage.buildView(JspViewDeclarationLanguage.java:91)
    at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:77)
    at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:199)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

How is this caused and how can I solve it?

标签: jsf tomcat7
3条回答
对你真心纯属浪费
2楼-- · 2020-02-06 07:48

Add jstl maven dependency in pom.xml:

         <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
查看更多
家丑人穷心不美
3楼-- · 2020-02-06 07:56

java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config

A ClassNotFoundException means that the specified class is missing in the runtime classpath. As the package name hints, it's part of JSTL.

JSF (more specifically, Facelets) has indeed a dependency on JSTL for the <c:xxx> tags. When JSF loads, it's implicitly also loading JSTL core taglib configuration. However, if it cannot be found, you'll get exactly this exception.

JSTL (and JSF!) is normally already provided out the box on Java EE container such as JBoss AS/EAP/WildFly, GlassFish, TomEE, WebLogic, etcetera. However, you're using Tomcat, which is a barebones JSP/Servlet container and doesn't ship with JSTL out the box. If upgrading to e.g. TomEE is not an option, you'd need to manuall supply JSTL along with the webapp, like as you did for JSF.

Just download jstl-1.2.jar and drop it in /WEB-INF/lib folder of your webapp, along with the JSF JAR(s).

See also:

查看更多
相关推荐>>
4楼-- · 2020-02-06 08:10

It seems you are missing lib. check if JSTL 1.1 - jstl.jar is added in your classpath.

查看更多
登录 后发表回答