自定义PhaseListener在jsf 2中调用两次

sah*_*hai 3 jsf-2

我正在使用JSF 2.0中的PhaseListener.但它的方法每次都被调用两次.

@Override
public void beforePhase(PhaseEvent arg0) {
    System.out.println("Start Phase "+arg0.getPhaseId()+" here the value "+ ++i +" object "+this);  
}
Run Code Online (Sandbox Code Playgroud)

和输出是这样的

Start Phase RESTORE_VIEW 1 here the value 1 object com.phaseListener.MyPhaseListener@cc8c29
Start Phase RESTORE_VIEW 1 here the value 1 object com.phaseListener.MyPhaseListener@106054a
Run Code Online (Sandbox Code Playgroud)

每次被两个不同的对象调用.

请让我知道,为什么会这样?

Eti*_*sne 5

如果这有助于某人谷歌搜索此问题.

在我的情况下,我从Glassfish 3移动到Tomcat 7,我注意到我的自定义阶段监听器被注册两次导致重复的日志条目.

在我的web.xml中,我有一个ConfigureListener,它是Glassfish 3所必需的,但会在Tomcat 7上触发第二次注册:

<listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
Run Code Online (Sandbox Code Playgroud)

我只是删除了这个块,它解决了这个问题.