1 Reply Latest reply on Apr 30, 2008 10:53 AM by Stan Silvert

    Facelets page with template throws NullPointerException

    Fabio Silva Newbie

      I'm testing the beta2 release of JSFUnit with JSF RI 1.2 and RichFaces 3.1.2. I've created a simple facelets page that uses a template:

      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:rich="http://richfaces.org/rich"
       xmlns:a4j="http://richfaces.org/a4j"
       template="/templates/default.xhtml">
       <ui:define name="body">
       <h:form id="form1">
       <h:messages></h:messages>
       <h:panelGrid columns="3" cellspacing="2" cellpadding="2" id="grid1">
       <h:outputLabel value="#{msg.label_enter_name}" for="txtName"
       id="label1" />
       <h:inputText id="txtName" value="#{nameBean.name}" required="true"
       label="#{msg.label_enter_name}" />
       <h:commandButton action="#{nameBean.process}"
       value="#{msg.button_continue}" id="button1" />
       </h:panelGrid>
       </h:form>
       </ui:define>
      </ui:composition>


      This page is rendered correctly in the browser. In my test case, when I try to instantiate a JSFClientSession for this page, the following exception is thrown:

      java.lang.NullPointerException at
      org.apache.xml.serializer.TreeWalker.startNode(TreeWalker.java:368) at
      org.apache.xml.serializer.TreeWalker.traverse(TreeWalker.java:143) at
      org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:389) at
      org.jboss.jsfunit.facade.DOMUtil.convertToDomLevel2(DOMUtil.java:143) at
      org.jboss.jsfunit.facade.JSFClientSession.updateInternalState(JSFClientSession.java:215) 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.<init>(JSFClientSession.java:82) at
      test.jsfunit.EnterNameTest.testEnterName(EnterNameTest.java:20) 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: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:122) at
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) 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:230) at
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179) at
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84) at
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at
      org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157) at
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241) at
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580) at
      org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at
      java.lang.Thread.run(Thread.java:595)


      However, if I remove the template attribute and the ui:define tag, the test completes succesfully.

      Does anybody know what's wrong here?

      Thanks.