4 Replies Latest reply on Mar 20, 2007 7:09 AM by serrgblues

    Troubles with using PhaseListener implementation

    serrgblues

      I use JBoss 4.0.4GA+JSF(1.2_04-b07-FCS)+Facelets(1.1.11)

      My web.xml file :

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="2.4"
       xmlns="http://java.sun.com/xml/ns/j2ee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
      
      
       <!-- Use Documents Saved as *.xhtml -->
       <context-param>
       <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
       <param-value>.jsf</param-value>
       </context-param>
      
       <!-- Special Debug Output for Development -->
       <context-param>
       <param-name>facelets.DEVELOPMENT</param-name>
       <param-value>true</param-value>
       </context-param>
      
       <!-- Optional JSF-RI Parameters to Help Debug -->
       <context-param>
       <param-name>com.sun.faces.validateXml</param-name>
       <param-value>true</param-value>
       </context-param>
       <context-param>
       <param-name>com.sun.faces.verifyObjects</param-name>
       <param-value>true</param-value>
       </context-param>
      
       <!-- Faces Servlet -->
       <servlet>
       <servlet-name>Faces Servlet</servlet-name>
       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
       </servlet>
      
       <!-- Faces Servlet Mapping -->
       <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>
       <url-pattern>*.xhtml</url-pattern>
       </servlet-mapping>
      
       <welcome-file-list>
       <welcome-file>index.html</welcome-file>
       </welcome-file-list>
      
      <security-constraint>
       <display-name>Restrict XHTML Documents</display-name>
       <web-resource-collection>
       <web-resource-name>JSF</web-resource-name>
       <url-pattern>*.jsf</url-pattern>
       </web-resource-collection>
       <auth-constraint>
       <description>Only Let 'developer's access JSF pages</description>
       <role-name>developer</role-name>
       </auth-constraint>
       </security-constraint>
      
       <security-role>
       <role-name>developer</role-name>
       </security-role>
      
      </web-app>
      


      And faces-config.xml file :
      <?xml version='1.0' encoding='UTF-8'?>
      <faces-config xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
       version="1.2">
      
       <application>
       <view-handler>
       com.sun.facelets.FaceletViewHandler
       </view-handler>
       </application>
      
      
       <!-- our NumberBean we just created -->
      
       <managed-bean>
       <managed-bean-name>loginBean</managed-bean-name>
       <managed-bean-class>com.fabulous_valley.managed_beans.login.LoginBean</managed-bean-class>
       <managed-bean-scope>session</managed-bean-scope>
       </managed-bean>
      
       <managed-bean>
       <managed-bean-name>prototypeBean</managed-bean-name>
       <managed-bean-class>com.fabulous_valley.PrototypeBean</managed-bean-class>
       <managed-bean-scope>session</managed-bean-scope>
       <managed-property>
       <property-name>testString</property-name>
       <value>test</value>
       </managed-property>
       </managed-bean>
      
      
      
      </faces-config>
      


      And all worked ...
      But if I try to use
       <lifecycle>
       <phase-listener>
       com.mydomen.web.MyPhaseListener
       </phase-listener>
       </lifecycle>
      


      in faces-config.xml, then in deploy stage I have next message :

      13:27:14,941 INFO [Server] JBoss (MX MicroKernel) [4.0.4.GA (build: CVSTag=JBoss_4_0_4_GA date=200605151000)] Started in 25s:970ms
      13:27:15,160 ERROR [[/]] StandardWrapper.Throwable
      java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory
      at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:256)
      at javax.faces.webapp.FacesServlet.init(FacesServlet.java:142)
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)
      at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932)
      at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3917)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4201)
      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)


      How can I fix this problem Help me please ...

        • 1. Re: Troubles with using PhaseListener implementation
          serrgblues

          Sorry ... after research I can see another error message :


          5:33:51,324 ERROR [STDERR] 15.03.2007 15:33:51 com.sun.faces.config.ConfigureListener configure
          SEVERE: Cant instantiate class: phase-listener: com.fabulous_valley.web.MyPhaseListener.
          15:33:51,324 ERROR [STDERR] java.lang.ClassCastException: com.fabulous_valley.web.MyPhaseListener
          15:33:51,324 ERROR [STDERR] at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:885)
          15:33:51,324 ERROR [STDERR] at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:536)
          15:33:51,324 ERROR [STDERR] at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:436)
          15:33:51,324 ERROR [STDERR] at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729)
          15:33:51,324 ERROR [STDERR] at org.apache.catalina.core.StandardContext.start(StandardContext.java:4187)
          15:33:51,324 ERROR [STDERR] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
          15:33:51,324 ERROR [STDERR] at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
          15:33:51,324 ERROR [STDERR] at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
          15:33:51,324 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          15:33:51,324 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          15:33:51,340 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          15:33:51,340 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
          .....


          How can I fix this? ....



          • 2. Re: Troubles with using PhaseListener implementation
            gcoleman

            It looks like your class com.fabulous_valley.web.MyPhaseListener does implement the PhaseListener interface.

            • 3. Re: Troubles with using PhaseListener implementation
              serrgblues

               

              "gcoleman" wrote:
              It looks like your class com.fabulous_valley.web.MyPhaseListener does implement the PhaseListener interface.


              this code of MyPhaseListener :

              package com.fabulous_valley.web;
              
              
              import javax.faces.event.PhaseListener;
              import javax.faces.event.PhaseEvent;
              import javax.faces.event.PhaseId;
              
              public class MyPhaseListener implements PhaseListener {
               public void afterPhase(PhaseEvent event) {}
              
               public void beforePhase(PhaseEvent event) {
               final PhaseId phase = event.getPhaseId();
               // ... some code ...
               }
              
               public PhaseId getPhaseId() {
               return PhaseId.ANY_PHASE;
               }
              }
              


              • 4. Re: Troubles with using PhaseListener implementation
                serrgblues

                Sorry. Is it not a problem?