简体   繁体   English

com.sun.faces.config.ConfigureListener 的配置

[英]Configuration of com.sun.faces.config.ConfigureListener

I'm reviewing a current JSF project where the web.xml configuration contains:我正在审查当前的 JSF 项目,其中web.xml配置包含:

  • the FacesServlet (configured on *.xhtml ) FacesServlet(在*.xhtml上配置)
  • the com.sun.faces.config.ConfigureListener com.sun.faces.config.ConfigureListener

I'm using JSF 2.2 and Mojarra implementation.我正在使用 JSF 2.2 和 Mojarra 实现。

I'm confused about the ConfigureListener .我对ConfigureListener感到困惑。 Is this class needed in the configuration?配置中需要这个类吗? What is the goal of this class?这门课的目标是什么? I couldn't find any information and the class has almost no javadoc.我找不到任何信息,而且该课程几乎没有 javadoc。

If I remove this configuration, everything seem to work the same way.如果我删除此配置,一切似乎都以相同的方式工作。 Thus I guess that the ConfigureListener could or should be removed but I am not sure.因此,我猜想可以或应该删除ConfigureListener ,但我不确定。

The ConfigureListener is normally automatically registered via /META-INF/jsf_core.tld file of Mojarra implementation JAR file. ConfigureListener通常通过 Mojarra 实现 JAR 文件的/META-INF/jsf_core.tld文件自动注册。 Additionally, the ConfigureListener is explicitly registered via a Servlet 3.0 ServletContainerInitializer in order to workaround an old GlassFish v3 bug (note: v3, not 3.0.x, thus really that one first GF3 version ever).此外, ConfigureListener通过 Servlet 3.0 ServletContainerInitializer显式注册,以解决旧的 GlassFish v3 错误(注意:v3,而不是 3.0.x,因此是有史以来第一个 GF3 版本)。

There exist situations wherein the auto-registration via .tld file is insufficient.存在通过.tld文件自动注册不足的情况。 The well known one is when the webapp is deployed to Jetty .众所周知,当 webapp 部署到Jetty 时 This is explained in detail in this Q&A: could not find Factory: javax.faces.context.FacesContextFactory .这在这个问答中有详细解释: 找不到工厂:javax.faces.context.FacesContextFactory

Also, as mentioned before and in that detailed answer, GlassFish v3 has a bug wherein the TLD file is scanned too late and thus JSF couldn't do its necessary initialization thing at the right moment.此外,正如之前和那个详细答案中提到的,GlassFish v3 有一个错误,其中 TLD 文件被扫描得太晚,因此 JSF 无法在正确的时间执行其必要的初始化操作。 You'd then need to explicitly register the ConfigureListener in webapp's web.xml .然后,您需要在 webapp 的web.xml显式注册ConfigureListener

But if it works for you when it's not explicitly registered in web.xml , then just keep it out.但是如果它没有在web.xml显式注册时对你web.xml ,那么就把它放在外面。 Less noise in web.xml is better. web.xml噪音越小越好。 But if you happen to possibly deploy to a container sensitive to the mentioned problem (so when your webapp is actually a publicly distributed one and you have no control over choice of target container), then you'd better keep it in "for the case that".但是,如果您碰巧可能部署到对上述问题敏感的容器(因此,当您的 web 应用程序实际上是一个公开分发的应用程序并且您无法控制目标容器的选择时),那么您最好将其保留在“对于这种情况”那”。


Update : It appears that Tomcat 8.x shows buggy behavior when this entry is enabled in web.xml : this listener will actually be executed twice instead of only once.更新:在web.xml启用此条目时,Tomcat 8.x 似乎显示错误行为:此侦听器实际上将执行两次而不是仅执行一次。 The consequence is disastrous: among others, all JSF event listeners will be registered twice and component libraries will be loaded twice.结果是灾难性的:除其他外,所有 JSF 事件侦听器都将被注册两次,组件库将被加载两次。 This leads only to conflicts during runtime.这只会在运行时导致冲突。 In other words, when deploying to Tomcat, make sure that this entry is removed from web.xml .换句话说,在部署到 Tomcat 时,请确保从web.xml删除此条目。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.ClassNotFoundException:com.sun.faces.config.ConfigureListener - java.lang.ClassNotFoundException : com.sun.faces.config.ConfigureListener 原因:java.lang.ClassNotFoundException:com.sun.faces.config.ConfigureListener - Caused By: java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener 如何解决用户定义的侦听器com.sun.faces.config.ConfigureListener失败:java.lang.NullPointerException? - How to resolve User defined listener com.sun.faces.config.ConfigureListener failed: java.lang.NullPointerException? 使用MyFaces与WASCE / Geronimo时的java.lang.ClassNotFoundException:com.sun.faces.config.ConfigureListener - java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener when using MyFaces with WASCE/Geronimo 部署jsp / servlet Web应用程序“ com.sun.faces.config.ConfigureListener”时,Jboss错误 - Error with Jboss while deploying a jsp/servlet web app “com.sun.faces.config.ConfigureListener” Error 无法加载servlet侦听器类:com.sun.faces.config.ConfigureListener - Unable to load servlet listener class: com.sun.faces.config.ConfigureListener com.sun.faces.config.InitFacesContext.cleanupInitMaps上的Nullpointer异常 - Nullpointer exception at com.sun.faces.config.InitFacesContext.cleanupInitMaps com.sun.faces.config.ConfigurationException:不存在web.xml - com.sun.faces.config.ConfigurationException: no web.xml present Spring-jsf Web应用程序Glassfish崩溃,但wildfly 10.x正确运行com.sun.faces.config.ConfigurationException:配置失败! 空值 - Spring-jsf Web app Glassfish Crashes but wildfly 10.x runs correctly com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null com.sun.faces.config.ConfigurationException:无法解析文档“ jndi:/localhost/NotowaniaGieldowe/WEB-INF/faces-config.xml”:null - com.sun.faces.config.ConfigurationException: Unable to parse document 'jndi:/localhost/NotowaniaGieldowe/WEB-INF/faces-config.xml': null
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM