7 Replies Latest reply on Feb 6, 2008 10:06 AM by Peter Lustig

    Seam events question

    Peter Lustig Newbie

      Hi there,

      is it possible to raise an event in the ejb and consume that event in a class residing in the war project?

      So if i fire the event in a class from project-jar.jar and consume it in project-war.jar ...

      I hope i could make it clear what i want to do.

      Regards,
      Jens

        • 1. Re: Seam events question
          Norman Richards Master

          That should not be a problem.

          • 2. Re: Seam events question
            Peter Lustig Newbie

            Ok, then maybe i am doing s.th. wrong, because in my case that seems not to work or this is a JSF "problem" i am trying to set some value onto a component binding when that event is fired, so i annotated the setter with

            @Observer("event")

            but when the method with
            @RaiseEvent("event") is fired, the Setter is not called ...

            Do you have any ideas, or maybe that's impossible?

            • 3. Re: Seam events question
              Pete Muir Master

              You'll need to use your debugger to see where the event is lost.

              Or open a JIRA and attach an example with reproduction steps so we can take a look.

              • 4. Re: Seam events question
                Gerhard Balthasar Newbie

                Most commen error is to forget to declare the Observer method on the interface, if it's a SessionBean.

                Greetz GHad

                • 5. Re: Seam events question
                  Peter Lustig Newbie

                  I followed gbc's advise and annotated RaiseEvent onto the method in the interface (may i didn't see this in the documentation) ... but now am facing some other problem, reflection does not seem to work. Both components the one from the web and ejb tier are session scoped, to avoid problems with instantiation (at least that's my thought ;))

                  javax.el.ELException: /index.xhtml: Could not invoke method by reflection: StatisticsState_$$_javassist_0.setHds_base(org.richfaces.component.UIDatascroller) with parameters: (org.jboss.seam.Component) on:
                   state.StatisticsState_$$_javassist_0
                   at com.sun.facelets.compiler.TextInstruction.write(TextInstruction.java:50)
                   at com.sun.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:39)
                   at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:280)
                   at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
                   at org.richfaces.renderkit.html.PanelBarItemRenderer.doEncodeChildren(PanelBarItemRenderer.java:165)
                   at org.richfaces.renderkit.html.PanelBarItemRenderer.doEncodeChildren(PanelBarItemRenderer.java:160)
                   at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121)
                   at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
                   at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
                   at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
                   at org.richfaces.renderkit.html.PanelBarRenderer.doEncodeChildren(PanelBarRenderer.java:148)
                   at org.richfaces.renderkit.html.PanelBarRenderer.doEncodeChildren(PanelBarRenderer.java:143)
                   at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121)
                   at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
                   at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
                   at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
                   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:216)
                   at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
                   at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
                   at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
                   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
                   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.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                   at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                   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:44)
                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                   at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
                   at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
                   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.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.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(Thread.java:595)
                  Caused by: javax.ejb.EJBTransactionRolledbackException: Could not invoke method by reflection: StatisticsState_$$_javassist_0.setHds_base(org.richfaces.component.UIDatascroller) with parameters: (org.jboss.seam.Component) on:
                   state.StatisticsState_$$_javassist_0
                   at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
                   at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
                   at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                   at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                   at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                   at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
                   at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                   at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                   at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                   at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:206)
                   at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:119)
                   at $Proxy157.fetchClientList(Unknown Source)
                   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.jboss.seam.util.Reflections.invoke(Reflections.java:21)
                   at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
                   at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
                   at org.jboss.seam.ejb.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:41)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                   at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                   at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
                   at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterce
                  10:26:49,651 ERROR [STDERR] ptor.java:54)
                   at org.javassist.tmp.java.lang.Object_$$_javassist_1.fetchClientList(Object_$$_javassist_1.java)
                   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.jboss.seam.util.Reflections.invoke(Reflections.java:21)
                   at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
                   at org.jboss.seam.Component.callComponentMethod(Component.java:2074)
                   at org.jboss.seam.Component.callCreateMethod(Component.java:1997)
                   at org.jboss.seam.Component.newInstance(Component.java:1968)
                   at org.jboss.seam.Component.getInstance(Component.java:1865)
                   at org.jboss.seam.Component.getInstance(Component.java:1832)
                   at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
                   at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
                   at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:166)
                   at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:53)
                   at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
                   at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
                   at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
                   at org.jboss.el.parser.AstValue.getValue(AstValue.java:63)
                   at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
                   at com.sun.facelets.el.ELText$ELTextVariable.writeText(ELText.java:184)
                   at com.sun.facelets.el.ELText$ELTextComposite.writeText(ELText.java:108)
                   at com.sun.facelets.compiler.TextInstruction.write(TextInstruction.java:45)
                   ... 58 more
                  Caused by: java.lang.IllegalArgumentException: Could not invoke method by reflection: StatisticsState_$$_javassist_0.setHds_base(org.richfaces.component.UIDatascroller) with parameters: (org.jboss.seam.Component) on:
                  state.StatisticsState_$$_javassist_0
                   at org.jboss.seam.util.Reflections.invoke(Reflections.java:31)
                   at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
                   at org.jboss.seam.Component.callComponentMethod(Component.java:2082)
                   at org.jboss.seam.core.Events.raiseEvent(Events.java:85)
                   at ui.xxxBean.sort(xxxBean.java:224)
                   at ui.xxxBean.fetchClientList(xxxBean.java:90)
                   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.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
                   at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
                   at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
                   at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                   at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                   at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                   at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:26)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                   at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:27)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                   at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
                   at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
                   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.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
                   at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                   at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                   at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                   at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
                   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                   at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
                   ... 112 more
                  Caused by: java.lang.IllegalArgumentException: argument type mismatch
                   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.jboss.seam.util.Reflections.invoke(Reflections.java:21)
                   ... 151 more
                  


                  Any ideas on this too?

                  • 6. Re: Seam events question
                    Pete Muir Master

                    You're trying to observe with a method which takes parameters, and not passing any, or the wrong, parameter.

                    • 7. Re: Seam events question
                      Peter Lustig Newbie

                      Pete, you're becoming sort of my new hero here, you were right!

                      The problem i have, that the change is not reflected in the UI after the action is executed may have s.th. to do with the JSF lifecycle i think.

                      I am trying to set the "current Page" to 1 on a rich:datascroller after executing a search action by fireing that event.

                      But that somehow does not work. Maybe i'm to late, because actions are triggered within invoke_application phase and the values are set on update_model_values phase?

                      Regards,
                      Jens