java.lang.ClassNotFoundException : com.sun.faces.config.ConfigureListener [英] java.lang.ClassNotFoundException : com.sun.faces.config.ConfigureListener

查看:37
本文介绍了java.lang.ClassNotFoundException : com.sun.faces.config.ConfigureListener的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们是三个开发 JSF 项目的人,我们以前从未接触过 JSF.奇怪的是,从 SVN 检出相同的数据,其中一名团队成员每次使用 Tomcat 7.0.27 时都会收到 404 错误.

We are three people developing a JSF project and we've not been into JSF before. Oddly, with the same data checked out from SVN, one of the team members gets an 404 error everytime using Tomcat 7.0.27.

Tomcat(Eclipse内部使用)启动时,写出如下日志:

At the time when Tomcat (used inside Eclipse) starts up, the following log is written out:

01.06.2012 11:45:16 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: ......
01.06.2012 11:45:16 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:SnapManCloud' did not find a matching property.
01.06.2012 11:45:16 org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
01.06.2012 11:45:16 org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
01.06.2012 11:45:16 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 677 ms
01.06.2012 11:45:16 org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
01.06.2012 11:45:16 org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.12
01.06.2012 11:45:17 org.apache.catalina.core.StandardContext listenerStart
FATAL: Error configuring application listener of class com.sun.faces.config.ConfigureListener
java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4638)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5204)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5199)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
01.06.2012 11:45:17 org.apache.catalina.core.StandardContext listenerStart
FATAL: Skipped installing application listeners due to previous error(s)
01.06.2012 11:45:17 org.apache.catalina.core.StandardContext startInternal
FATAL: Error listenerStart
01.06.2012 11:45:17 org.apache.catalina.core.StandardContext startInternal
FATAL: Context [/SnapManCloud] startup failed due to previous errors
01.06.2012 11:45:17 org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["http-bio-8080"]
01.06.2012 11:45:17 org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
01.06.2012 11:45:17 org.apache.catalina.startup.Catalina start
INFO: Server startup in 1279 ms

我们使用 Mojarra 2.0.3 作为 JSF-Implementation,它已被 Eclipse 包含到项目中(并且可能包含在类路径中).

We are using Mojarra 2.0.3 as JSF-Implementation which has been included by Eclipse into the project (and presumably into the classpath).

确实在web.xml

<listener>
     <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>

有没有人有任何起点可以查找错误?另外,如果需要其他信息,请告诉我.

Does anyone have any starting point where to look for the error? Also, if additional information is required, please let me know.

推荐答案

JSF 通常捆绑在成熟的 Java EE 应用服务器中,例如 GlassFish、JBoss AS/EAP、WildFly、WebSphere、WebLogic 等.然而,Tomcat 是一个准系统 JSP/Servlet 容器,只捆绑了 JSP 和 Servlet API,没有 JSF API.

JSF is usually bundled in full fledged Java EE application servers such as GlassFish, JBoss AS/EAP, WildFly, WebSphere, WebLogic, etc. However, Tomcat is a barebones JSP/Servlet container which bundles only the JSP and Servlet APIs, no JSF API.

如果您想在 Tomcat 上使用 JSF,那么您需要将 JSF 库与 webapp 捆绑在其 /WEB-INF/lib 文件夹中,或者通过以下方式在 Tomcat 中安装 JSF将 JSF 库放在其 /lib 文件夹中.显然,该应用程序是为真正的 Java EE 应用程序服务器设计的,因此没有在 /WEB-INF/lib 中捆绑 JSF 库.

If you want to use JSF on Tomcat, then you'd need to bundle the JSF libraries along with the webapp in its /WEB-INF/lib folder, or to install JSF in Tomcat by placing the JSF libraries in its /lib folder. Apparently that application is designed for real Java EE applications servers and hence doesn't bundle the JSF libraries in /WEB-INF/lib.

有两种 JSF 实现可用,Mojarra我的面孔.com.sun.faces 包表示 Mojarra,因此下载该包并将其放在 webapp 的运行时类路径中(即在 webapp 的 /WEB-INF/lib 或 Tomcat 的 <代码>/lib).

There are two JSF implementations available, Mojarra and MyFaces. The com.sun.faces package indicates Mojarra, so download that one and put it in webapp's runtime classpath (i.e. either in webapp's /WEB-INF/lib or in Tomcat's /lib).

另一个可能的原因是您将项目部署到使用 MyFaces 而不是 Mojarra 的 Java EE 应用程序服务器,而该项目显然最初是为 Mojarra 开发的.那个监听器是特定于 Mojarra 的.在这种情况下,您最好从 web.xml 中删除整个 条目.

Another possible cause is that you deployed the project to a Java EE application server which uses MyFaces instead of Mojarra, while the project was apparently initially developed for Mojarra. That listener is namely Mojarra specific. In such case, you'd better remove the entire <listener> entry from web.xml.

在任何情况下,在 web.xml 中显式注册 Mojarra 的 ConfigureListener 实际上只需要解决旧的有问题的服务器,例如无法找到的 GlassFish v3 和 JettyMojarra 的 TLD 文件中的侦听器.当部署到合适的服务器时,不需要整个 条目.

In any case, the explicit registration of Mojarra's ConfigureListener in web.xml is actually only necessary to workaround old buggy servers such as GlassFish v3 and Jetty who failed to find the listener in Mojarra's TLD file. When deployed to a decent server, the whole <listener> entry is unnecessary.

这篇关于java.lang.ClassNotFoundException : com.sun.faces.config.ConfigureListener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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