8 Replies Latest reply on Aug 31, 2010 12:10 PM by babu bobba

    java.lang.IllegalStateException: FacesContext already releas

    Pankaj Rode Newbie

      Hi All,

      I am getting the above exception when I try to execute the following Test Case

      JSFClientSession client = new JSFClientSession("/faces/logon.jsp");
      client.setParameter("userID", "SimMan");
      client.setParameter("password", "sdm");
      client.submit("login");


      Executing the very first line throws the following exception:

      The stack Trace is as below

      FacesContext already released
      at org.apache.myfaces.context.servlet.ServletFacesContextImpl.getExternalContext(ServletFacesContextImpl.java:100)
      at org.jboss.jsfunit.context.JSFUnitFacesContext.getExternalContext(JSFUnitFacesContext.java:135)
      at org.jboss.jsfunit.context.JSFUnitFacesContext.release(JSFUnitFacesContext.java:193)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:161)
      at com.msc.sdm.web.faces.SmFacesServlet.service(SmFacesServlet.java:79)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
      at com.msc.sdm.web.filters.ResolveFileFilter.forward(ResolveFileFilter.java:455)
      at com.msc.sdm.web.filters.ResolveFileFilter.smDoFilter(ResolveFileFilter.java:168)
      at com.msc.sdm.web.filters.ResolveFileFilter.doFilter(ResolveFileFilter.java:54)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:96)
      at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:220)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
      at java.lang.Thread.run(Unknown Source)



      Thanks in Advance!!!

        • 1. Re: java.lang.IllegalStateException: FacesContext already re
          Stan Silvert Master

          You can get this error if the JSFUnit FacesContext Factory is installed twice. I know this can happen if you have two JSFUnit jars in your classpath.

          See http://www.jboss.com/index.html?module=bb&op=viewtopic&t=125032

          Stan

          • 2. Re: java.lang.IllegalStateException: FacesContext already re
            Pankaj Rode Newbie

            Thanks Stan.

            I had removed

            jboss-jsfunit-core-1.0.0.Beta2-sources.jar from WEb-INF/lib

            and it'w working fine!!!

            Thanks again for your great help.

            • 3. Re: java.lang.IllegalStateException: FacesContext already re
              Harinath C Newbie

              Hi Stan,

               

              I have similar issue with new JSFUnit [jboss-jsfunit-1.2.0.Final]. I check the lib folder and i dont have any duplicates.

              Appreicate if you can help me figure this out.

               

              Thanks,

              jh

               

              Here is the error stack

               

              java.lang.IllegalStateException: FacesContext already released
                  at org.apache.myfaces.context.servlet.FacesContextImpl.setViewRoot(FacesContextImpl.java:253)
                  at org.jboss.jsfunit.context.JSFUnitFacesContext.setViewRoot(JSFUnitFacesContext.java:121)
                  at org.ajax4jsf.resource.ResourceLifecycle.send(ResourceLifecycle.java:153)
                  at org.ajax4jsf.resource.InternetResourceService.load(InternetResourceService.java:334)
                  at org.ajax4jsf.cache.LRUMapCache.load(LRUMapCache.java:116)
                  at org.ajax4jsf.cache.LRUMapCache.get(LRUMapCache.java:87)
                  at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:195)
                  at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:141)
                  at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:486)
                  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:233)
                  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
                  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
                  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:447)
                  at java.lang.Thread.run(Thread.java:619)

              • 4. Re: java.lang.IllegalStateException: FacesContext already re
                Stan Silvert Master

                Hi Harinath,

                 

                Sorry for the late reply.  What version of JSF are you using?  I'm suspecting that there may be a problem with Mojarra JSF2.

                 

                Stan

                • 5. Re: java.lang.IllegalStateException: FacesContext already re
                  Stan Silvert Master

                  A new bug has been uncovered that can cause this problem if you deploy two WAR for JSFUnit testing.  It can also happen after a redeploy.

                   

                  See https://jira.jboss.org/browse/JSFUNIT-253

                   

                  Stan

                  • 6. Re: java.lang.IllegalStateException: FacesContext already re
                    babu bobba Newbie

                    Hi Stan,

                       I have same issue, I am trying to test with JSFUnit1.3.0.Final and JSFUnitRichfaces1.3.0.Final

                    We use versions

                    JSF: 1.1
                    MyFaces: 1.1.3
                    RichFaces: 3.1.6
                    Tomahawk: 2.0
                    Spring: 1.2.8
                    Hibernate: 3.0.5

                     

                    I tried every thing, If I comment below lines in web.xml, My test suites are executed though, My application failed since extensionsFilter is commented.

                    <filter>
                    <filter-name>richfaces</filter-name>
                    <filter-class>org.ajax4jsf.Filter</filter-class>
                    <display-name>RichFaces Filter</display-name>
                    </filter>
                    <filter>
                    <filter-name>extensionsFilter</filter-name>
                    <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
                    </filter>


                    Please suggest me what need to be done.


                    Here is stack trace:

                     

                    java.lang.IllegalStateException: FacesContext already released
                    at org.apache.myfaces.context.servlet.ServletFacesContextImpl.release(ServletFacesContextImpl.java:296)
                    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:161)

                    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
                    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
                    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
                    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:122)
                    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
                    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
                    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
                    at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
                    at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
                    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
                    at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
                    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
                    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
                    at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
                    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
                    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3242)
                    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
                    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
                    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2010)
                    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1916)
                    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1366)
                    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
                    at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)


                    Thanks,
                    Babu.

                    • 7. Re: java.lang.IllegalStateException: FacesContext already re
                      Stan Silvert Master

                      Hi Babu,

                       

                      I'm wondering if this really has anything to do with JSFUnit.  I don't see the JSFUnitFilter or any other JSFUnit class in your stack trace.

                       

                      Stan

                      • 8. Re: java.lang.IllegalStateException: FacesContext already re
                        babu bobba Newbie

                        Hi Stan,

                         

                          Thanks somuch for you quick reply, I was working on this, This issue resolved.

                         

                        I called ServletTestRunner through JSF instead a direct call, I used WebClient for this, direct call is failing though,

                        appreciate you have suggestion.

                         

                         

                         

                        Thanks,

                        Babu.