4 Replies Latest reply on Sep 13, 2011 5:50 AM by dimaria06

    richfaces in seam project

    Corneliu Ene Newbie

      I tried to use a4j:push in my seam project. I got this:

      10:25:17,387 INFO [STDOUT] PushBean.addListener()
      10:25:17,387 ERROR [STDERR] 03.05.2008 10:25:17 com.sun.facelets.FaceletViewHandler handleRenderException
      SEVERE: Error Rendering View[/push.xhtml]
      javax.el.ELException: /push.xhtml @10,61 eventProducer="#{push.addListener}": java.lang.ClassCastException: org.ajax4jsf.webapp.PushEventsCounter cannot be cast to org.ajax4jsf.event.PushEventListener
       at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:74)
       at org.ajax4jsf.component.UIPush.encodeBegin(UIPush.java:57)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:934)
       at javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:826)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:942)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
       at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
       at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:189)
       at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
       at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
       at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)
       at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
       at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
       at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
       at java.lang.Thread.run(Unknown Source)
      Caused by: java.lang.ClassCastException: org.ajax4jsf.webapp.PushEventsCounter cannot be cast to org.ajax4jsf.event.PushEventListener
       at com.enec.alpha.data.PushBean.addListener(PushBean.java:36)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:329)
       at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:342)
       at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
       at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
       at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
       at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
       ... 52 more
      10:25:17,387 INFO [STDOUT] returned
      


      Even PushBean is declared in faces-config, or as stateful ejb (just added seam annotations), the error message is the same.

      I used Seam 2.0.1 GA or 2.1.0 CR1 and Richfaces 3.2.1 SVN or 3.2.1 CR3.

        • 1. Re: richfaces in seam project
          Ilya Shaikovsky Master

          please show your source for the page and the bean.

          My example for RF demo commited to SVN has no more such error. Initially it was but caused by my fault ;)

          • 2. Re: richfaces in seam project
            Corneliu Ene Newbie

            i didn't change anything.

            bean:

            package com.enec.alpha.data;
            
            import java.util.Date;
            import java.util.EventListener;
            import java.util.EventObject;
            import java.util.UUID;
            
            import org.ajax4jsf.event.PushEventListener;
            
            /**
             * @author Ilya Shaikovsky
             *
             */
            
            public class PushBean implements Runnable {
            
             private String uuid = "";
            
             private boolean enabled = false;
            
             private Date startDate;
            
             PushEventListener listener;
            
             private Thread thread;
            
             // private int eventsFired counter;
            
             public void addListener(EventListener listener) {
             synchronized (listener) {
             System.out.println("PushBean.addListener()");
             if (this.listener != listener) {
             this.listener = (PushEventListener) listener;
             }
             }
             }
            
             public void run() {
             System.out.println("PushBean.run() executed");
             while (thread != null) {
             try {
             System.out.println(((new Date()).getTime()-startDate.getTime())>=60000);
             if (((new Date()).getTime()-startDate.getTime())>=20000) {
             stop();
             }
             uuid = UUID.randomUUID().toString();
             listener.onEvent(new EventObject(this));
             Thread.sleep(10000);
             } catch (InterruptedException e) {
             // TODO Auto-generated catch block
             // e.printStackTrace();
             }
             }
             }
            
             public String getUuid() {
             System.out.println(uuid + "returned");
             return uuid;
             }
            
             public void start() {
             if (thread == null) {
             thread = new Thread(this);
             thread.setDaemon(true);
             thread.start();
             System.out.println("PushBean.start()");
             setStartDate(new Date());
             setEnabled(true);
             System.out.println("thread started");
             }
             }
            
             public void stop() {
             if (thread != null) {
             //thread.stop();
             setStartDate(null);
             setEnabled(false);
             thread = null;
             }
             }
            
             public Thread getThread() {
             return thread;
             }
            
             public boolean isEnabled() {
             return enabled;
             }
            
             public void setEnabled(boolean enabled) {
             this.enabled = enabled;
             }
            
             public Date getStartDate() {
             return startDate;
             }
            
             public void setStartDate(Date startDate) {
             this.startDate = startDate;
             }
            }
            


            ...and page:
            <ui:composition xmlns="http://www.w3.org/1999/xhtml"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:h="http://java.sun.com/jsf/html"
             xmlns:f="http://java.sun.com/jsf/core"
             xmlns:a4j="http://richfaces.org/a4j"
             xmlns:rich="http://richfaces.org/rich">
            
             <h:form>
             <a4j:push interval="1000" eventProducer="#{push.addListener}"
             reRender="push,out" enabled="#{push.enabled}" id="push"/>
             <rich:panel>
             <f:facet name="header">
             <h:outputText value="Push Example"/>
             </f:facet>
             <h:panelGrid columns="1" id="out">
             <h:outputText rendered="#{!push.enabled}" value="Press Start to run push example"/>
             <h:panelGroup rendered="#{push.enabled}">
             <h:outputText value="Generated UUID:"/>
             <h:outputText value="#{push.uuid}"/>
             </h:panelGroup>
             <h:panelGroup>
             <a4j:commandButton value="Start" action="#{push.start}"
             ajaxSingle="true" rendered="#{!push.enabled}" reRender="push"/>
             <a4j:commandButton value="Stop" action="#{push.stop}"
             ajaxSingle="true" rendered="#{push.enabled}" reRender="push"/>
             </h:panelGroup>
             </h:panelGrid>
             </rich:panel>
             </h:form>
            </ui:composition>


            ...and faces-config:

            ...
             <managed-bean>
             <managed-bean-name>push</managed-bean-name>
             <managed-bean-class>
             com.enec.alpha.data.PushBean
             </managed-bean-class>
             <managed-bean-scope>session</managed-bean-scope>
             </managed-bean>
            ...


            Only that my project is a seam project. Could be some problems with others libraries?

            • 3. Re: richfaces in seam project
              Corneliu Ene Newbie

              my fault...

              i had put richfaces-api, richfaces-impl and richfaces-ui in both ear/lib and ear/war/WEB-INF/lib.

              Correct is: richfaces-api in ear/lib and richfaces-impl richfaces-ui in /ear/war/WEB-INF/lib.

              now it works.

              Thanks.

              • 4. Re: richfaces in seam project
                dimaria06 Newbie

                Hello all.

                 

                i am still have the same problem on Corneliu Ene . I am trying to implement ajax push using a4j:push on My JSF Project . i am get the error on load page :

                 

                Sep 13, 2011 4:27:24 PM com.sun.faces.lifecycle.Phase doPhase

                SEVERE: JSF1054: (Phase ID: RENDER_RESPONSE 6, View ID: /push.jsp) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@8c858a]

                Sep 13, 2011 4:27:24 PM org.ajax4jsf.webapp.BaseXMLFilter doXmlFilter

                SEVERE: Exception in the filter chain

                javax.servlet.ServletException: /push.jsp(17,8) '#{push.addListener}' java.lang.ClassCastException: org.ajax4jsf.webapp.PushEventsCounter cannot be cast to dev.vnx.PushData.PushEventListener

                    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)

                i had put richfaces-api, richfaces-impl and richfaces-ui on the same directory as : WebContent\WEB-INF\lib.

                 

                we don't have in ear/lib directory as the Seam project .

                 

                 

                Please can anyone help me, thanks.