5 Replies Latest reply on Mar 3, 2010 11:56 AM by Stan Silvert

    JSFServerSession is null

    tamara rojo Newbie

      Hello,

       

       

      I have a problem. When I do this, "JSFServerSession server = jsfSession.getJSFServerSession();", server is null. I think it's a configuration problem but can not find the problem.

       

      Could anyone help me?

       

      Thanks,

      Tamara

        • 1. Re: JSFServerSession is null
          Stan Silvert Master

          Hi Tamara,

           

          Can you post the rest of your code?  Also, are there any errors in the server log or in JUnit reports?

           

          Stan

          • 2. Re: JSFServerSession is null
            tamara rojo Newbie

            this is my code of JSFunit test :

             

            import org.apache.cactus.ServletTestCase;

            import org.jboss.jsfunit.jsfsession.JSFClientSession;

            import org.jboss.jsfunit.jsfsession.JSFServerSession;

            import org.jboss.jsfunit.jsfsession.JSFSession;

             

            public class Prueba extends ServletTestCase{

             

            private JSFClientSession client;

            private JSFServerSession server;

             

            public void setUp() throws IOException

               {

                  // Initial JSF request

            JSFSession jsfSession = new JSFSession("/mapaCliente.init.faces");

                this.server = jsfSession.getJSFServerSession();

                this.client = jsfSession.getJSFClientSession();

               

               }

             

            public void testInitialPage() throws IOException

               {

                  assertNotNull(client.getContentPage());

                

                  // Test navigation to initial viewID

                  assertEquals("/mapaCliente.jsp", server.getCurrentViewID());

            }

            public void testSetCheckbox() throws IOException

                  {

                     client.click("marcador"); // uncheck it

                     client.click("submit");

                     assertFalse((Boolean)server.getManagedBeanValue("#{siniestro.siniestro.showMarker}"));

             

                     client.click("marcador"); // make it checked again

                     client.click("submit");

                     assertTrue((Boolean)server.getManagedBeanValue("#{siniestro.siniestro.showMarker}"));

                  }

             

             

            And this is the error:

             

            testInitialPageErrornull

             

            java.lang.NullPointerException
            at org.jboss.jsfunit.jsfsession.JSFServerSession.getCurrentViewID(JSFServerSession.java:76)
            at com.lda.jsfunit.Prueba.testInitialPage(Prueba.java:35)
            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.jboss.jsfunit.framework.JSFUnitServletRedirector.doPost(JSFUnitServletRedirector.java:46)
            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 org.jboss.jsfunit.framework.JSFUnitServletRedirector.doGet(JSFUnitServletRedirector.java:52)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
            at org.jboss.jsfunit.framework.JSFUnitFilter.doFilter(JSFUnitFilter.java:116)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
            at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
            at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
            at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
            at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
            at java.lang.Thread.run(Thread.java:619)

             

            This is a picture of my variables when I do  this:

             

                this.server = jsfSession.getJSFServerSession();

                 this.client = jsfSession.getJSFClientSession();

             

            debug.jpg

            And the file tomcat.txt containing the error trace of tomcat.


            Thanks,

            Tamara

            • 3. Re: JSFServerSession is null
              Stan Silvert Master

              This looks like a config problem in web.xml.  Can you post your web.xml file?

               

              Stan

              • 4. Re: JSFServerSession is null
                tamara rojo Newbie

                This is my web.xml.

                 

                 

                Thanks,

                Tamara

                • 5. Re: JSFServerSession is null
                  Stan Silvert Master

                  This is a bit unusual:

                  JSFSession jsfSession = new JSFSession("/mapaCliente.init.faces");

                   

                  I suspect that if you did this you would see an error page:

                  System.out.println(client.getContentPage());

                   

                  I think when you start your JSFSession it is not rendering a proper JSF response.  This needs to work in a browser for it to work in JSFUnit:

                  http://localhost:8080/mywebapp/mapaCliente.init.faces


                  Normally, I would expect something like:

                  JSFSession jsfSession = new JSFSession("/mapaCliente.faces");

                   

                  Perhaps you should try that.


                  Also, I see some references in your web.xml to com.ibm.ws.jsf config params and and IBM JSResourceServlet.  From the stack trace it doesn't look like you are using WebSphere.  But if you are then you need to look at JSFUnitOnWebSphere

                   

                  Stan