2 Replies Latest reply on Mar 27, 2007 9:19 AM by Mike Quilleash

    Seam and Ajax4jsf combination throws IllegalStateException

    Mike Quilleash Newbie

      Seam 1.1.6
      Ajax4Jsf 1.1.0
      JSF RI 1.2_02

      Hi there,

      I am getting an odd problem with Seam and Ajax4jsf. After each phase the AjaxPhaseListener tries to access it's AjaxContext which it does by getting the JSF application and trying to resolve a variable name.

      In the restore view phase I get this exception thrown

      27-Mar-2007 09:57:42 com.sun.faces.lifecycle.LifecycleImpl phase
      WARNING: phase(RESTORE_VIEW 1,com.sun.faces.context.FacesContextImpl@cf020d) threw exception: java.lang.IllegalStateException: No phase id bound to current thread (make sure you do not have two SeamPhaseListener instances installed) No phase id bound to current thread (make sure you do not have two SeamPhaseListener instances installed)
      org.jboss.seam.contexts.PageContext.getPhaseId(PageContext.java:153)
      org.jboss.seam.contexts.PageContext.isRenderResponsePhase(PageContext.java:165)
      org.jboss.seam.contexts.PageContext.getCurrentReadableMap(PageContext.java:76)
      org.jboss.seam.contexts.PageContext.get(PageContext.java:66)
      org.jboss.seam.contexts.Contexts.lookupInStatefulContexts(Contexts.java:160)
      org.jboss.seam.Component.getInstance(Component.java:1635)
      org.jboss.seam.Component.getInstance(Component.java:1630)
      org.jboss.seam.jsf.SeamELResolver.getValue(SeamELResolver.java:49)
      javax.el.CompositeELResolver.getValue(CompositeELResolver.java:52)
      com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:62)
      com.sun.faces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:75)
      org.ajax4jsf.framework.ajax.AjaxContext.getCurrentInstance(AjaxContext.java:150)
      org.ajax4jsf.framework.renderer.AjaxPhaseListener.afterPhase(AjaxPhaseListener.java:76)
      com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:274)
      com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:113)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:96)
      org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:220)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      com.azure.spark.web.servlet.filter.SecurityFilter.doFilter(SecurityFilter.java:73)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:212)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
      org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
      java.lang.Thread.run(Thread.java:595)
      


      I've checked the obvious, only one phase listener. Looking at the registered phase listeners the Ajax one is before/outside the Seam one and I noticed the Seam phase listener does Lifecycle.setPhaseId( null ) in it's afterPhase method. This means that when Ajax4jsf comes to do it's search for this context object it runs into the above exception when Seam searches it's PageContext because the afterPhase of AjaxPL runs after the afterPhase of SeamPL which sets the phaseid to null.

      I recently upgraded to Ajax4jsf 1.1.0 and I don't think this error was occurring before (it just gets logged as a warning but I check my logs pretty regularly). Has anyone else seen this problem between the two before?

      Thanks,

      Mike.