7 Replies Latest reply on Apr 7, 2009 7:59 AM by Stan Silvert

    null Exception

    maddula lalitha Newbie


      Hi Stan ,


      The following is the error I am getting while running JsfUnit Test suite with ant in Tomcat 6.0



      java.lang.NullPointerException
      at org.jboss.jsfunit.framework.FaceletsErrorPageException.isFaceletsErrorPage(FaceletsErrorPageException.java:55)
      at org.jboss.jsfunit.framework.FaceletsErrorPageDetector.afterRequest(FaceletsErrorPageDetector.java:39)
      at org.jboss.jsfunit.framework.JSFUnitWebConnection.notifyListenersAfter(JSFUnitWebConnection.java:103)
      at org.jboss.jsfunit.framework.JSFUnitWebConnection.getResponse(JSFUnitWebConnection.java:84)
      at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1487)
      at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1445)
      at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:323)
      at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:384)
      at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:369)
      at org.jboss.jsfunit.framework.SimpleInitialRequestStrategy.doInitialRequest(SimpleInitialRequestStrategy.java:48)
      at org.jboss.jsfunit.framework.WebClientSpec.doInitialRequest(WebClientSpec.java:244)
      at org.jboss.jsfunit.jsfsession.JSFSession.(JSFSession.java:80)
      at org.jboss.jsfunit.jsfsession.JSFSession.(JSFSession.java:57)
      at JSFUnitTest.setUp(Unknown Source)
      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:690)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.jboss.jsfunit.framework.JSFUnitFilter.doFilter(JSFUnitFilter.java:116)
      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:228)
      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:104)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
      at java.lang.Thread.run(Thread.java:619)


      Please help me regarding this


      Regards,
      Lalitha.M

        • 1. Re: null Exception
          Stan Silvert Master

          Very odd. It looks like this must have returned null from HtmlUnit:

          at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1487)

          What does your test code look like? Your test class is JSFUnitTest.class? With no package?
          at JSFUnitTest.setUp(Unknown Source)


          Stan

          • 2. Re: null Exception
            maddula lalitha Newbie

            Hi Stan,

            My Test class is JSFUnitTest .I am posting it here.please check it .


            // A JSFServerSession gives you access to JSF state
            JSFServerSession server = jsfSession.getJSFServerSession();

            // Test navigation to initial viewID
            assertEquals("/index.jsp", server.getCurrentViewID());
            /* WebResponseImpl w=null;
            w.getResponseBody();
            */
            // Assert that the prompt component is in the component tree and rendered
            UIComponent prompt = server.findComponent("greeting");
            assertTrue(prompt.isRendered());


            }
            }

            • 3. Re: null Exception
              maddula lalitha Newbie

              Hi Stan,

              My Test class is JSFUnitTest .I am posting it here.please check it .

              package JsfUnit;

              import java.io.IOException;

              import javax.faces.component.UIComponent;

              import junit.framework.Test;
              import junit.framework.TestSuite;

              import org.jboss.jsfunit.jsfsession.JSFClientSession;
              import org.jboss.jsfunit.jsfsession.JSFServerSession;
              import org.jboss.jsfunit.jsfsession.JSFSession;
              import org.xml.sax.SAXException;

              /*import com.gargoylesoftware.htmlunit.WebResponseImpl;
              */

              public class JSFUnitTest extends org.apache.cactus.ServletTestCase
              {
              public static Test suite()
              {
              return new TestSuite( JSFUnitTest.class );
              }

              public void testInitialPage() throws IOException, SAXException
              {

              // Send an HTTP request for the initial page
              JSFSession jsfSession = new JSFSession("/example.faces");

              // A JSFClientSession emulates the browser and lets you test HTML
              JSFClientSession client = jsfSession.getJSFClientSession();

              // A JSFServerSession gives you access to JSF state
              JSFServerSession server = jsfSession.getJSFServerSession();

              // Test navigation to initial viewID
              assertEquals("/index.jsp", server.getCurrentViewID());
              /* WebResponseImpl w=null;
              w.getResponseBody();
              */
              // Assert that the prompt component is in the component tree and rendered
              UIComponent prompt = server.findComponent("greeting");
              assertTrue(prompt.isRendered());

              }
              }

              • 4. Re: null Exception
                Stan Silvert Master

                Looking again at my code, you should see an IOException too. That's the stack trace that we need. Did you find an IOException?

                Stan

                • 5. Re: null Exception
                  maddula lalitha Newbie

                  Stan,

                  The error is not yet resolved and moreover I am not getting any IOException.

                  Lalitha

                  • 6. Re: null Exception
                    maddula lalitha Newbie

                    can u please send me a simple example with faces-config and web.xml and mention the envinorments to deploy that example.

                    Lalitha

                    • 7. Re: null Exception
                      Stan Silvert Master

                      We have sample WARs for several different containers on this page:
                      http://www.jboss.org/community/docs/DOC-9819

                      Hope that helps.

                      Stan