0 Replies Latest reply on Jul 23, 2012 2:39 AM by Sabarinath Selvaraj

    FacesServlet threw exception: java.lang.NullPointerException

    Sabarinath Selvaraj Newbie

      Hi

       

      I m using a4j:commandButton to call the method in managed bean.It shows the following error and not able to call the method present in the managed bean.

       

      Servlet.service() for servlet FacesServlet threw exception: java.lang.NullPointerException

      [Server:WebNode1]       at com.sun.faces.context.PartialViewContextImpl.createPartialResponseWriter(PartialViewContextImpl.java:441) [jsf-impl-2.1.7-jbossorg-2.jar:]

      [Server:WebNode1]       at com.sun.faces.context.PartialViewContextImpl.access$300(PartialViewContextImpl.java:71) [jsf-impl-2.1.7-jbossorg-2.jar:]

      [Server:WebNode1]       at com.sun.faces.context.PartialViewContextImpl$DelayedInitPartialResponseWriter.getWrapped(PartialViewContextImpl.java:582) [jsf-impl-2.1.7-jbossorg-2.jar:]

      [Server:WebNode1]       at javax.faces.context.PartialResponseWriter.startDocument(PartialResponseWriter.java:115) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

      [Server:WebNode1]       at com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:199) [jsf-impl-2.1.7-jbossorg-2.jar:]

      [Server:WebNode1]       at com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerImpl.java:123) [jsf-impl-2.1.7-jbossorg-2.jar:]

      [Server:WebNode1]       at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119) [jsf-impl-2.1.7-jbossorg-2.jar:]

      [Server:WebNode1]       at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116) [jsf-impl-2.1.7-jbossorg-2.jar:]

      [Server:WebNode1]       at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]

      [Server:WebNode1]       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

      [Server:WebNode1]       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]

      [Server:WebNode1]       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

      [Server:WebNode1]       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]

      [Server:WebNode1]       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]

      [Server:WebNode1]       at org.jboss.modcluster.container.jbossweb.JBossWebContext$RequestListenerValve.event(JBossWebContext.java:67)

      [Server:WebNode1]       at org.jboss.modcluster.container.jbossweb.JBossWebContext$RequestListenerValve.invoke(JBossWebContext.java:48)

      [Server:WebNode1]       at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

      [Server:WebNode1]       at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]

      [Server:WebNode1]       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]

      [Server:WebNode1]       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]

      [Server:WebNode1]       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]

      [Server:WebNode1]       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]

      [Server:WebNode1]       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]

      [Server:WebNode1]       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]

      [Server:WebNode1]       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]

      [Server:WebNode1]       at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_06]

       


      If I change <a4j:commandButton> to <h:commandButton> then the method present in the managed bean is called but not able to navigate the next page.[but i m configured the navigation rule in faces-config.xml ]

       

       

      Page:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
            xmlns:f="http://java.sun.com/jsf/core"
            xmlns:rich="http://richfaces.org/rich"
            xmlns:a4j="http://richfaces.org/a4j">
      <f:loadBundle basename="messages" var="msg"/>
      <h:body>
      <ui:composition> 
          <h:form id="purchaseform" prependId="false">
      <table style="background-color: White;" border="0" cellpadding="3" cellspacing="3" width="100%">
      <tr>
        <td>
         <ui:include page="sample.xhtml" />
        </td>
      </tr>
      <tr>
      <td>
           <table id="FirstScreen" style="width: 100%;" border="0">
        <tr>
         <td colspan="3"> </td>
        </tr>
       
        <tr>
         <td valign="top" style="width: 50%">
          <table class="summary" style="width: 100%;">
          
           <tr>
            <td><h:outputLabel value="State" /></td>
            <td><h:outputLabel value="#{SampleManagedBead.state}" id="state"/>
            <h:inputHidden value="#{SampleManagedBead.state}" />
            </td>
           </tr>
           <tr>
            <td><h:outputLabel value="Zipcode" /></td>
            <td><h:outputLabel value="#{SampleManagedBead.zip}" id="zip" />
            <h:inputHidden value="#{SampleManagedBead.zip}"/>
            </td>
           </tr>
           <tr>
            <td><h:outputLabel value="Phone Number" /></td>
            <td><h:outputLabel value="#{SampleManagedBead.phoneNumber}" id="phoneNumber"/>
            <h:inputHidden value="#{SampleManagedBead.phoneNumber}"  />
            </td>
           </tr>
           <tr>
            <td><h:outputLabel value="Email Address" /></td>
            <td><h:outputLabel value="#{SampleManagedBead.emailAddress}" id="emailAddress"/>
            <h:inputHidden value="#{SampleManagedBead.emailAddress}"  />
            </td>
           </tr>
          </table>
         </td>
         <td style="width: 50%">
          <table>
          
           <tr>
            <td>
           
           <-- Here the method present in managed bean is called but not able to navigate the next page-->
            <h:commandButton action="#{SampleManagedBead.pay()}" value="Continue--&gt;" >
            </h:commandButton>
           
            <-- Here the method present in managed bean is not called -->
            <a4j:commandButton action="#{SampleManagedBead.pay()}" value="Continue--&gt;" execute="@this" />
           
            </td>
           </tr>
          </table>
         </td>
        </tr>
       
      </table>   
      </td>
      </tr>
      </table>
      <h:inputHidden value="#{SampleManagedBead.cvv}" />
      <h:inputHidden value="#{SampleManagedBead.Premium}" />
      <h:inputHidden value="#{SampleManagedBead.RequestId}" />

      </h:form>
      </ui:composition>
      </h:body></html>

       

      faces-config.xml:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <faces-config xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd"
      version="2.1">

      <application>
        <locale-config>
         <default-locale>fr_FR</default-locale>
         <supported-locale>ta</supported-locale>
         <supported-locale>en</supported-locale>
        </locale-config>

        <resource-bundle>
         <base-name>messages</base-name>
         <var>msg</var>
        </resource-bundle>
      </application>

      <navigation-rule>
        <from-view-id>*</from-view-id>
        <navigation-case>
         <from-action>#{SampleManagedBead.pay}</from-action>
         <from-outcome>success</from-outcome>
         <to-view-id>/test.xhtml</to-view-id>  
        </navigation-case>
        <navigation-case>
         <from-action>#{SampleManagedBead.pay}</from-action>
         <from-outcome>failure</from-outcome>
         <to-view-id>/Purchase.xhtml</to-view-id>
        </navigation-case>
      </navigation-rule>

      </faces-config>

       

      Thanks in Advance,

      Sabarinath