14 Replies Latest reply on Dec 5, 2007 7:35 AM by Stan Silvert

    Null pointer Exception in FacesContextBridge

    Raja sekhar v Newbie

      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

        • 1. Re: Null pointer Exception in FacesContextBridge
          Stan Silvert Master

          I don't understand why you are doing this:

          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);


          Why are you trying to manage the request yourself? Is there something that you are unable to do with JSFClientSession?

          Stan

          • 2. Re: Null pointer Exception in FacesContextBridge
            Raja sekhar v Newbie

            i want to submit a ajax request.
            I am using normal jsf components not rich or ajaxfor jsf so why i am using that code.
            Thanks
            Raja

            • 3. Re: Null pointer Exception in FacesContextBridge
              Stan Silvert Master

              Oh yes, now I remember. For anyone else, looking at this post, he's on the cutting edge as he's following "Roll your own Ajax client" from here:
              http://wiki.jboss.org/wiki/AjaxWithJSFUnit

              You shouldn't need to set the "Cactus_Service" param. Let your test be called by Cactus normally. You also don't need to set the JSESSIONID yourself. That is already set as a cookie in the WebConversation.

              In your test, start with a JSFClientSession object and let it make the initial request. So the initial request returns your custom ajax JSF component.

              JSFClientSession client = new JSFClientSession("/mypage.faces");


              I remember that you said you didn't want the request to contain all the params from your form. There is a helper class called WebRequestFactory that will help you create the next request. However, it does include all the params. So you can call one of its public methods and then remove the params you don't want or you can just copy this private method:

              private PostMethodWebRequest makePostRequest(String actionURL)
               {
               WebResponse latestResponse = client.getWebResponse();
               String protocol = latestResponse.getURL().getProtocol();
               String host = latestResponse.getURL().getHost();
               String port = Integer.toString(latestResponse.getURL().getPort());
               return new PostMethodWebRequest(protocol + "://" + host + ":" + port + actionURL);
               }


              Then add your extra params to the PostMethodWebRequest. Then pass that to JSFClientSession.doWebRequest().

              Stan


              • 4. Re: Null pointer Exception in FacesContextBridge
                Raja sekhar v Newbie

                Thanks stan

                I just confused, i followed what you have said in
                http://wiki.jboss.org/wiki/AjaxWithJSFUnit
                (you said these steps to me before you written this)

                i am showing the steps i followed

                WebResponse webResponse= client.getWebResponse();
                Document doc= client.getUpdatedDOM();

                WebRequestFactory fact=new WebRequestFactory(client);

                PostMethodWebRequest request1=fact.buildRequest(form.getAction(),"postForm");

                request1.setParameter("aazones","zipZone,stateZone");
                request1.setParameter("aaxmlrequest","true");
                request1.setParameter("AjaxAnywhere.refreshZones","zipZone,stateZone");
                request1.setParameter("AJAXREQUEST", "postForm");


                client.doWebRequest(request1);
                WebResponse newResponse = client.getWebResponse();

                Document doc2=client.getUpdatedDOM();


                String html="";
                try{
                html=DOMUtil .docToHTMLString(doc2);
                }
                catch(Exception ee){

                }
                doc=doc2;

                session.setAttribute(JSFUnitFilter.ALT_RESPONSE, client.getUpdatedDOM().getTextContent());
                String urlString = "/ServletRedirector";
                GetMethodWebRequest request2 = new GetMethodWebRequest((new StringBuilder()).append(getWarURL()).append(urlString).toString());

                are these steps right or am i did some thing wrong?
                And if i wont pass cacts_service it is throwing null pointer function(cactus_service value not found)

                Are you saying this right

                • 5. Re: Null pointer Exception in FacesContextBridge
                  Stan Silvert Master

                  I'm sorry. I didn't realize that you were all the way up to step 8.

                  So for that, you are correct to create a GetMethodWebRequest() and you do need to set the JSESSIONID. You don't need to pass cactus_service. When the JSFUnitFilter sees that JSFUnitFilter.ALT_RESPONSE has been set in the session it will return your response before it ever hits the Cactus ServletRedirector.

                  Stan

                  • 6. Re: Null pointer Exception in FacesContextBridge
                    Raja sekhar v Newbie

                    Thanks Stan

                    I am getting the following exception in my browser if i wont give the Cactus_Service as parameter

                    com.meterware.httpunit.HttpInternalErrorException: Error on HTTP request: 500 Internal Error [http://localhost:8888/ValuationRequest/ServletRedirector?JSESSIONID=0aed191e22b85075e6072ea149b2ac19b0e9b5ad2694]
                    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 com.cccis.valuescope.JsfUnitTest.KeyDataTest.testClaimDataRendered(KeyDataTest.java:327)
                    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)
                    at java.lang.Thread.run(Thread.java:595)




                    And in my server log i am having this exception

                    javax.servlet.ServletException: Missing service name parameter [Cactus_Service] in HTTP request. Received query string is [JSESSIONID
                    =0aed191e22b85075e6072ea149b2ac19b0e9b5ad2694].

                    at org.apache.cactus.internal.server.AbstractWebTestController.getServiceName(AbstractWebTestController.java:171)

                    at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestController.java:81)

                    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[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java
                    :64)

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

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

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

                    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler
                    .java:866)

                    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler
                    .java:448)

                    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler
                    .java:216)

                    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:117)

                    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:110)

                    at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)

                    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor
                    .java:303)

                    at java.lang.Thread.run(Thread.java:595)



                    could u please see this

                    • 7. Re: Null pointer Exception in FacesContextBridge
                      Stan Silvert Master

                      The request should not be passing all the way through the JSFUnitFilter to Cactus. The JSFUnitFilter should see JSFUnitFilter.ALT_RESPONSE and return immediately.

                      How are you getting the session?

                      What are you doing between setting JSFUnitFilter.ALT_RESPONSE and calling client.doWebRequest()?

                      Stan

                      • 8. Re: Null pointer Exception in FacesContextBridge
                        Raja sekhar v Newbie

                        Actually i am extending the test class itself so we are extending the ServletTestCase so i can directly use session object

                        i am showing the snippet i have in my code these are the lines i have in between

                        String urlString = "/ServletRedirector";
                        GetMethodWebRequest request2 = new GetMethodWebRequest((new StringBuilder()).append(getWarURL()).append(urlString).toString());
                        request2.setParameter("JSESSIONID", session.getId());

                        this GetmethodWebRequest parameter value is http://localhost:8888/ValuationRequest/ServletRedirector

                        is it clear now?

                        • 9. Re: Null pointer Exception in FacesContextBridge
                          Stan Silvert Master

                          OK. I think that's your problem then. I think you are getting a reference to the wrong session.

                          You should get the session like this:

                          HttpSession session = (HttpSession)externalContext.getSession();


                          Or this should work as well:
                          HttpSession session = WebConversationFactory.getSessionFromThreadLocal();


                          Stan

                          • 10. Re: Null pointer Exception in FacesContextBridge
                            Raja sekhar v Newbie

                            Thank you stan

                            I get the session object as you said

                            HttpSession session = (HttpSession)externalContext.getSession();

                            but it s the same exception i am getting again

                            In my server log i got the following

                            javax.servlet.ServletException: Missing service name parameter [Cactus_Service] in HTTP request. Received query string is [JSESSIONID
                            =0aed191e22b849682429b3344c70a430b04c7077d56f].

                            at org.apache.cactus.internal.server.AbstractWebTestController.getServiceName(AbstractWebTestController.java:171)

                            at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestController.java:81)

                            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[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java
                            :64)

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

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

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

                            at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler
                            .java:866)

                            at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler
                            .java:448)

                            at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler
                            .java:216)

                            at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:117)

                            at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:110)

                            at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)

                            at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor
                            .java:303)

                            at java.lang.Thread.run(Thread.java:595)



                            and in my browser

                            Error on HTTP request: 500 Internal Error [http://localhost:8888/ValuationRequest/ServletRedirector?JSESSIONID=0aed191e22b849682429b3344c70a430b04c7077d56f]

                            com.meterware.httpunit.HttpInternalErrorException: Error on HTTP request: 500 Internal Error [http://localhost:8888/ValuationRequest/ServletRedirector?JSESSIONID=0aed191e22b849682429b3344c70a430b04c7077d56f]
                            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 com.cccis.valuescope.JsfUnitTest.KeyDataTest.testClaimDataRendered(KeyDataTest.java:333)
                            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)
                            at java.lang.Thread.run(Thread.java:595)


                            what could be the reason?

                            • 11. Re: Null pointer Exception in FacesContextBridge
                              Raja sekhar v Newbie

                              And i found that both session values are same..............

                              so?
                              Will makeWebConversation()
                              in WebConversatioin will help us?

                              • 12. Re: Null pointer Exception in FacesContextBridge
                                Stan Silvert Master

                                You don't want to make a new WebConversation. You need to keep using the one inside the JSFClientSession.

                                You need to figure out why this code in JSFUnitFilter isn't working:

                                String altResponseString = removeAltResponse(request);
                                 if (altResponseString != null)
                                 {
                                 sendAltResponse(response, altResponseString);
                                 return;
                                 }


                                Stan

                                • 13. Re: Null pointer Exception in FacesContextBridge
                                  Raja sekhar v Newbie

                                  Thanks stan

                                  HttpSession session = WebConversationFactory.getSessionFromThreadLocal();

                                  This is not possible as getSessionFromThreadLocal is protected and the constructor of this class is private.

                                  Which session will this gives to me?

                                  HttpSession mySession = (HttpSession)externalContext.getSession(true);


                                  my project sessioin or jsfunit session
                                  I thinks this is giving jsfunit session,right?

                                  in which session i need to place the attribute ALT_RESPONSE

                                  • 14. Re: Null pointer Exception in FacesContextBridge
                                    Stan Silvert Master

                                    This should return the correct session.
                                    HttpSession mySession = (HttpSession)externalContext.getSession(true);

                                    Here is how I get the session for this in JSFAJAX.java:

                                    private static HttpSession getSession()
                                     {
                                     return (HttpSession)FacesContext.getCurrentInstance()
                                     .getExternalContext()
                                     .getSession(true);
                                     }

                                    Just don't use ExternalContext.getSessionMap(). For that, the write-through is disabled.

                                    From what I see on this end, you code should be working. Maybe you could write another servlet filter to debug the session and find out why it is not seeing the attribute you set.

                                    Stan