3 Replies Latest reply on Jul 9, 2008 2:04 PM by Stan Silvert

    Getting nullpointer exception while running the jsf unit tes

    Bala Hanumanthu Newbie

      Hi,
      I am new to JSFUnit and i am writing simple jsfunit test case like
      public void setUp() throws IOException, SAXException
      {
      // Initial JSF request
      this.client = new JSFClientSession("/faces/equote/enterYourZip.jspx");
      }

      /**
      * @return the suite of tests being tested.
      */
      public static Test Suite(){
      return new TestSuite(EnterYourZipTestCase.class);
      }
      /**
      * The initial page was called up in the setUP() method.This shows some simple JSFUnit tests.
      * @throws IOException
      * @throws SAXException
      */
      public void testinitialPage() throws IOException,SAXException{
      JSFServerSession server=new JSFServerSession(client);
      //assertEquals("/enterYourZip.jspx", server.getCurrentViewID());

      UIComponent text01=server.findComponent("text01");
      assertTrue(text01.isRendered());


      }

      After running this test case in browser i am getting the nullpointerexception.can anyone help me how to resolve the issue.


      null

      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.updateInternalState(JSFClientSession.java:211)
      at org.jboss.jsfunit.facade.JSFClientSession.doWebRequest(JSFClientSession.java:201)
      at org.jboss.jsfunit.facade.JSFClientSession.doInitialRequest(JSFClientSession.java:131)
      at org.jboss.jsfunit.facade.JSFClientSession.(JSFClientSession.java:82)
      at com.aigdirect.cih.JSFUnitTestCases.EnterYourZipTestCase.setUp(EnterYourZipTestCase.java:37)
      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.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:995)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:930)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:145)
      at org.jboss.jsfunit.framework.JSFUnitFilter.doFilter(JSFUnitFilter.java:122)
      at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
      at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:766)
      at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:674)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:498)
      at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:464)
      at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3276)
      at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:267)
      at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
      at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1455)
      at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:113)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:454)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:383)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:263)
      at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
      at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
      at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
      at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
      at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
      at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
      at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
      at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
      at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873)
      at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1469)

        • 1. Re: Getting nullpointer exception while running the jsf unit
          Stan Silvert Master

          This error is usually due to a configuration issue. Can you post your web.xml?

          Stan

          • 2. Re: Getting nullpointer exception while running the jsf unit
            Bala Hanumanthu Newbie

            My web.xml file

            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
            <web-app>
            <display-name>CIHInternet</display-name>
            CIHInternet
            <context-param>
            <param-name>
            org.apache.myfaces.trinidad.DISABLE_CONTENT_COMPRESSION
            </param-name>
            <param-value>true</param-value>
            </context-param>

            <context-param>
            <param-name>application-name</param-name>
            <param-value>CIHInternet</param-value>

            The name of the application - basically, a way to get the
            display-name from the servlets.

            </context-param>
            <context-param id="ContextParam_1">
            <param-name>UseDeviceMapping</param-name>
            <param-value>false</param-value>
            </context-param>
            <context-param id="ContextParam_2">
            <param-name>ObjectTreeTransformType</param-name>
            <param-value>XSTREAM</param-value>
            </context-param>
            <context-param id="ContextParam_3">
            <param-name>RequestContextMapFileURI</param-name>
            <param-value>
            http://localhost/Advisor/iAdvisorWeb/desktop/contextmap.jsp
            </param-value>
            </context-param>
            <context-param id="ContextParam_4">
            <param-name>RequestContextMapFactoryClass</param-name>
            <param-value>
            com.chordiant.cafe.common.CafeContextMapFactory
            </param-value>
            </context-param>
            <context-param>
            <param-name>
            org.apache.myfaces.trinidad.ALTERNATE_VIEW_HANDLER
            </param-name>
            <param-value>com.sun.facelets.FaceletViewHandler</param-value>
            </context-param>
            <context-param>
            <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
            <param-value>.jspx</param-value>
            </context-param>
            <context-param>
            <param-name>
            org.apache.myfaces.trinidad.ENABLE_LIGHTWEIGHT_DIALOGS
            </param-name>
            <param-value>true</param-value>
            </context-param>
            <context-param>

            <param-name>facelets.DEVELOPMENT</param-name>
            <param-value>false</param-value>
            </context-param>
            <context-param>
            <param-name>facelets.VIEW_MAPPINGS</param-name>
            <param-value>/faces/*; *.jspx</param-value>
            </context-param>
            <context-param>
            <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
            <param-value>client</param-value>

            DO NOT CHANGE State saving method: "client" or "server" (=
            default) See JSF Specification 2.5.2

            </context-param>
            <context-param>
            <param-name>
            org.apache.myfaces.trinidad.CHECK_FILE_MODIFICATION
            </param-name>
            <param-value>true</param-value>
            </context-param>
            <context-param>
            <param-name>
            org.apache.myfaces.trinidad.CHANGE_PERSISTENCE
            </param-name>
            <param-value>session</param-value>
            </context-param>
            <context-param>
            <param-name>javax.faces.CONFIG_FILES</param-name>
            <param-value>
            /WEB-INF/equote/faces-config-nav.xml,
            /WEB-INF/equote/faces-config-bean.xml,
            </param-value>

            Comma separated list of URIs of (additional) faces config
            files. (e.g. /WEB-INF/my-config.xml) See JSF 1.0 PRD2,
            10.3.2

            </context-param>

            <filter-name>trinidad</filter-name>
            <filter-class>
            org.apache.myfaces.trinidad.webapp.TrinidadFilter
            </filter-class>


            <filter-name>JSFUnitFilter</filter-name>
            <filter-class>org.jboss.jsfunit.framework.JSFUnitFilter</filter-class>

            <filter-mapping>
            <filter-name>JSFUnitFilter</filter-name>
            <servlet-name>ServletTestRunner</servlet-name>
            </filter-mapping>
            <filter-mapping>
            <filter-name>JSFUnitFilter</filter-name>
            <servlet-name>ServletRedirector</servlet-name>
            </filter-mapping>


            <filter-mapping>
            <filter-name>trinidad</filter-name>
            <servlet-name>faces</servlet-name>
            </filter-mapping>



            <listener-class>
            com.chordiant.web.faces.listener.SessionListener
            </listener-class>


            <servlet-name>XmlLoader</servlet-name>
            <servlet-class>
            com.chordiant.cafe.servlets.XmlLoader
            </servlet-class>


            <servlet-name>GetResourceServlet</servlet-name>
            <servlet-class>
            com.chordiant.aep.admin.pm.resources.servlets.GetResourceServlet
            </servlet-class>


            <servlet-name>ResourceManagerServlet</servlet-name>
            <servlet-class>
            com.chordiant.aep.admin.pm.resources.servlets.ResourceManagerServlet
            </servlet-class>


            <servlet-name>faces</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            <load-on-startup>1</load-on-startup>


            <servlet-name>resources</servlet-name>
            <servlet-class>
            org.apache.myfaces.trinidad.webapp.ResourceServlet
            </servlet-class>


            <servlet-name>ServletRedirector</servlet-name>
            <servlet-class>org.apache.cactus.server.ServletTestRedirector</servlet-class>


            <servlet-name>ServletTestRunner</servlet-name>
            <servlet-class>org.apache.cactus.server.runner.ServletTestRunner</servlet-class>





            <servlet-mapping id="ServletMapping_34">
            <servlet-name>XmlLoader</servlet-name>
            <url-pattern>
            /servlet/com.chordiant.cafe.servlets.XmlLoader
            </url-pattern>
            </servlet-mapping>
            <servlet-mapping>
            <servlet-name>GetResourceServlet</servlet-name>
            <url-pattern>/GetResourceServlet</url-pattern>
            </servlet-mapping>
            <servlet-mapping>
            <servlet-name>ResourceManagerServlet</servlet-name>
            <url-pattern>/ResourceManagerServlet</url-pattern>
            </servlet-mapping>
            <servlet-mapping>
            <servlet-name>faces</servlet-name>
            <url-pattern>/faces/*</url-pattern>
            </servlet-mapping>
            <servlet-mapping>
            <servlet-name>resources</servlet-name>
            <url-pattern>/adf/*</url-pattern>
            </servlet-mapping>
            <servlet-mapping>
            <servlet-name>resources</servlet-name>
            <url-pattern>/chrd/*</url-pattern>
            </servlet-mapping>
            <servlet-mapping>
            <servlet-name>ServletRedirector</servlet-name>
            <url-pattern>/ServletRedirector</url-pattern>
            </servlet-mapping>
            <servlet-mapping>
            <servlet-name>ServletTestRunner</servlet-name>
            <url-pattern>/ServletTestRunner</url-pattern>
            </servlet-mapping>


            <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
            <taglib-location>/WEB-INF/c.tld</taglib-location>

            </web-app>

            • 3. Re: Getting nullpointer exception while running the jsf unit
              Stan Silvert Master

              I just noticed from the stack trace that you are running on WebSphere. This jira task points to a workaround for you: http://jira.jboss.com/jira/browse/JSFUNIT-68

              BTW, I'm still looking for someone who knows an API call to get the WebSphere cache ID. If you happen to know, I can try to fix the problem for good.

              Stan