8 Replies Latest reply on Dec 4, 2007 7:54 AM by Raja sekhar v

    java.lang.IllegalStateException: FacesContext already releas

    Raja sekhar v Newbie

      With the latest jar i took (beta version) my code is not working.
      it is showing java.lang.IllegalStateException: FacesContext already released

      This is the exception i can see on browser.............

      at com.meterware.httpunit.WebClient.validateHeaders(WebClient.java:573)
      at com.meterware.httpunit.WebClient.updateClient(WebClient.java:464)
      at com.meterware.httpunit.WebWindow.updateWindow(WebWindow.java:139)
      at com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:130)
      at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:121)
      at com.meterware.httpunit.WebClient.getResponse(WebClient.java:113)
      at org.jboss.jsfunit.facade.JSFClientSession.doWebRequest(JSFClientSession.java:184)
      at org.jboss.jsfunit.facade.JSFClientSession.doInitialRequest(JSFClientSession.java:122)
      at org.jboss.jsfunit.facade.JSFClientSession.(JSFClientSession.java:75)
      at com.cccis.valuescope.JsfUnitTest.KeyDataTest.setUp(KeyDataTest.java:58)


      where as in server log i got

      at org.apache.myfaces.context.servlet.ServletFacesContextImpl.getExternalContext(ServletFacesContextImpl.java:100)

      at org.jboss.jsfunit.context.JSFUnitFacesContext.getExternalContext(JSFUnitFacesContext.java:114)

      at org.jboss.jsfunit.context.JSFUnitFacesContext.release(JSFUnitFacesContext.java:170)

      at org.jboss.jsfunit.context.JSFUnitFacesContext.valueUnbound(JSFUnitFacesContext.java:201)

      at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.EvermindHttpSession.removeAttribute(EvermindHttpSession
      .java:231)

      at org.jboss.jsfunit.framework.JSFUnitFilter.doFilter(JSFUnitFilter.java:127)


      am i using any old jars or what? please let me know what is the problem

        • 1. Re: java.lang.IllegalStateException: FacesContext already re
          Raja sekhar v Newbie

          this.client = new JSFClientSession("/Login.faces");

          This is the line where it is throwing exception.

          And to your information it is not a jsf it is a jsp(initial page) it workied earlier.

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

            It looks like two JSFUnitFacesContextFactory instances were installed. Check to make sure that you don't have two different jsfunit-core jars in your classpath.

            Stan

            • 3. Re: java.lang.IllegalStateException: FacesContext already re
              Raja sekhar v Newbie

              Thank you stan

              I checked i didnt find any duplicate jars.
              it is not given any warning while start up also
              FacesContext already released is what the exception
              is it really related to duplication of jars?

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

                I'm pretty sure you do have two jsfunit-core jars in your classpath. I just recreated your problem that way.

                Look in WEB-INF/lib of your WAR. You will probably see two different jars like:
                jboss-jsfunit-core-1.0-beta-1.jar
                jboss-jsfunit-core-1.0-SNAPSHOT.jar

                Stan

                • 5. Re: java.lang.IllegalStateException: FacesContext already re
                  Raja sekhar v Newbie

                  Thank you stan
                  You are right boss-jsfunit-core-1.0-SNAPSHOT.jar
                  is there in APP-INF/LIB AND WEB-INF/LIB
                  We just took the latest build my team mate did this mistake
                  sorry stan

                  • 6. Re: java.lang.IllegalStateException: FacesContext already re
                    Raja sekhar v Newbie

                    Thank you stan

                    GetMethodWebRequest request2 = new GetMethodWebRequest((new StringBuilder()).append(getWarURL()).append(urlString).toString());
                    request2.setParameter("JSESSIONID", session.getId());
                    request2.setParameter("Cactus_Service", "RUN_TEST");
                    client.doWebRequest(request2);

                    When it calls doWebRequest() it is throwing the following exception
                    I traced it is throwing in FacesContextBridge class

                    HttpSession session = WebConversationFactory.getSessionFromThreadLocal();
                    JSFUnitFacesContext facesContext = (JSFUnitFacesContext)session.getAttribute(JSFUnitFacesContext.SESSION_KEY);
                    facesContext.setInstanceToJSFUnitThread();

                    May be it is not getting sessionFromThreadLocal or SEESION_KEY is not assigned


                    I am getting this exception... in my browser


                    java.lang.NullPointerException
                    at org.jboss.jsfunit.framework.FacesContextBridge.getCurrentInstance(FacesContextBridge.java:54)
                    at org.jboss.jsfunit.facade.ClientIDs.(ClientIDs.java:60)
                    at org.jboss.jsfunit.facade.JSFClientSession.doWebRequest(JSFClientSession.java:185)
                    at com.cccis.valuescope.JsfUnitTest.KeyDataTest.testClaimDataRendered(KeyDataTest.java:325)
                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    at org.apache.cactus.internal.AbstractCactusTestCase.runBareServer(AbstractCactusTestCase.java:153)
                    at org.apache.cactus.internal.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:119)
                    at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestController.java:93)
                    at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody1$advice(AbstractWebTestController.java:224)
                    at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java)
                    at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(ServletTestRedirector.java:101)
                    at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(ServletTestRedirector.java:224)
                    at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java)
                    at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTestRedirector.java:72)
                    at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody1$advice(ServletTestRedirector.java:224)
                    at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java)
                    at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
                    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
                    at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
                    at org.jboss.jsfunit.framework.JSFUnitFilter.doFilter(JSFUnitFilter.java:123)
                    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:621)
                    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:368)
                    at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:866)
                    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:448)
                    at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:216)
                    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:117)
                    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:110)
                    at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
                    at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
                    at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
                    at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
                    at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)





                    And in my logs Response already has been commited

                    Response has already been committed

                    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.EvermindHttpServletResponse.sendError(EvermindHttpServletResponse
                    .java:1128)

                    at com.sun.facelets.FaceletViewHandler.handleFaceletNotFound(FaceletViewHandler.java:633)

                    at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:585)

                    at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352)

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

                    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java
                    :64)

                    at org.ajaxanywhere.AAFilter.doFilter(AAFilter.java:43)

                    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher
                    .java:621)


                    Please let me know why i am getting this............
                    thank you

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

                      Glad to help.

                      Please start a new thread for each new question.

                      Thanks,

                      Stan

                      • 8. Re: java.lang.IllegalStateException: FacesContext already re
                        Raja sekhar v Newbie

                        thanks stan

                        I have started a new thread