10 Replies Latest reply on May 23, 2013 1:32 PM by manso

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

    manso Newbie

      I'm working in a JSF web application, in JBoss AS 7.1.1.Final. The application is deployed without errors and the pages are oppened, but when I fire any action (h:commandButton or h:commandLink), the server throws the following exception:

       

       

      ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/Projeto316].[Faces Servlet]] (http-localhost-127.0.0.1-8080-4) Servlet.service() for servlet Faces Servlet threw exception: java.lang.NullPointerException
                at com.sun.faces.context.PartialViewContextImpl.createPartialResponseWriter(PartialViewContextImpl.java:441) [jsf-impl-2.1.7-jbossorg-2.jar:]
                at com.sun.faces.context.PartialViewContextImpl.access$300(PartialViewContextImpl.java:71) [jsf-impl-2.1.7-jbossorg-2.jar:]
                at com.sun.faces.context.PartialViewContextImpl$DelayedInitPartialResponseWriter.getWrapped(PartialViewContextImpl.java:582) [jsf-impl-2.1.7-jbossorg-2.jar:]
                at javax.faces.context.PartialResponseWriter.startDocument(PartialResponseWriter.java:115) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
                at org.primefaces.context.PrimePartialResponseWriter.startDocument(PrimePartialResponseWriter.java:133) [primefaces-3.4.2.jar:]
                at com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:199) [jsf-impl-2.1.7-jbossorg-2.jar:]
                at com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerImpl.java:123) [jsf-impl-2.1.7-jbossorg-2.jar:]
                at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119) [jsf-impl-2.1.7-jbossorg-2.jar:]
                at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116) [jsf-impl-2.1.7-jbossorg-2.jar:]
                at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]
                at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
                at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79) [primefaces-3.4.2.jar:]
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
                at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
                at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_07]
      

       

      It follows my web.xml:

       

       

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="2.5" 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-app_2_5.xsd">
                <display-name>PRJ_312</display-name>
                <context-param>
                          <param-name>PARAMETER_ENCODING</param-name>
                          <param-value>UTF-8</param-value>
                </context-param>
                <context-param>
                          <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
                          <param-value>server</param-value>
                </context-param>
                <context-param>
                          <param-name>javax.faces.PROJECT_STAGE</param-name>
                          <param-value>Development</param-value>
                </context-param>
                <context-param>
                          <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                          <param-value>.xhtml</param-value>
                </context-param>
                <context-param>
                          <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
                          <param-value>true</param-value>
                </context-param>
        
                <servlet>
                          <servlet-name>Faces Servlet</servlet-name>
                          <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                          <load-on-startup>1</load-on-startup>
                </servlet>
                <servlet-mapping>
                          <servlet-name>Faces Servlet</servlet-name> 
                          <url-pattern>*.jsf</url-pattern>
                          <url-pattern>*.xhtml</url-pattern>
                </servlet-mapping>
                <session-config>
                          <session-timeout>30</session-timeout>
                </session-config>
                <welcome-file-list>
                          <welcome-file>index.html</welcome-file>
                </welcome-file-list>    
                <filter>
                          <filter-name>PrimeFaces FileUpload Filter</filter-name>
                          <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
                </filter>
        
                  <mime-mapping>
              <extension>png</extension>
              <mime-type>image/png</mime-type>
          </mime-mapping>
        
                <filter-mapping>
                          <filter-name>PrimeFaces FileUpload Filter</filter-name>
                          <servlet-name>Faces Servlet</servlet-name>
                </filter-mapping>
      
      
                <context-param>
                          <param-name>com.sun.faces.writeStateAtFormEnd</param-name>
                          <param-value>false</param-value>
                </context-param>
        
                <context-param>
                          <param-name>javax.faces.FACELETS_BUFFER_SIZE</param-name>
                          <param-value>65535</param-value>
                </context-param>
      
      
                <context-param>
                          <param-name>com.sun.faces.spi.AnnotationProvider</param-name>
                          <param-value>com.sun.faces.config.AnnotationScanner</param-value>
                </context-param>
        
                <context-param>
           <param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
           <param-value>false</param-value> 
                </context-param>
        
      </web-app>
      
      

       

      Someone can help me?

        • 1. Re: Servlet.service() for servlet Faces Servlet threw exception: java.lang.NullPointerException
          Nicklas Karlsson Master

          Does your application bundle the JSF impl like the parameter says? Because the stack trace show versions looking very much like the ones expected on the server side.

          • 2. Re: Servlet.service() for servlet Faces Servlet threw exception: java.lang.NullPointerException
            manso Newbie

            Nicklas Karlsson wrote:

             

            Does your application bundle the JSF impl like the parameter says? Because the stack trace show versions looking very much like the ones expected on the server side.

             

            Yes, the application bundle the jsf-impl-2.1.7.jar and jsf-api-2.1.7.jar, to solve the problem described in http://stackoverflow.com/q/14500693/1868709

             

            If I set the org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL to 'true', the server throws the following exception:

             

            SEVERE [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-1) Critical error during deployment: : com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! Class org.jboss.as.web.deployment.jsf.JandexAnnotationProvider is not an instance of com.sun.faces.spi.AnnotationProvider
                      at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:375) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]
                      at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:225) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]
                      at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
                      at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
                      at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
                      at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
                      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
                      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) [rt.jar:1.6.0_07]
                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) [rt.jar:1.6.0_07]
                      at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_07]
            Caused by: javax.faces.FacesException: Class org.jboss.as.web.deployment.jsf.JandexAnnotationProvider is not an instance of com.sun.faces.spi.AnnotationProvider
                      at com.sun.faces.spi.AnnotationProviderFactory.createAnnotationProvider(AnnotationProviderFactory.java:78) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]
                      at com.sun.faces.config.ConfigManager$AnnotationScanTask.<init>(ConfigManager.java:807) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]
                      at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:348) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]
                      ... 9 more
            
            • 4. Re: Servlet.service() for servlet Faces Servlet threw exception: java.lang.NullPointerException
              manso Newbie

              This issue relates to application wich uses the bundled jsf libs (when org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL to 'true'  ). When org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL is 'false', the server was supposed to load its embedded modules.

              • 5. Re: Servlet.service() for servlet Faces Servlet threw exception: java.lang.NullPointerException
                Nicklas Karlsson Master

                Ah, misread the param-value. Not sure what the AS does when the value is set to false but the libs are still bundled.

                • 6. Re: Servlet.service() for servlet Faces Servlet threw exception: java.lang.NullPointerException
                  manso Newbie

                  As shown in log, the server loads its embedded module (jsf-impl-2.1.7-jbossorg-2.jar), but it seems like the server cant build a session for the managed bean created.

                  • 7. Re: Servlet.service() for servlet Faces Servlet threw exception: java.lang.NullPointerException
                    Stan Silvert Master

                    Have you tried upgrading JSF within AS instead of bundling?

                     

                    The impl jar goes in modules/com/sun/jsf-impl/main.  Update modules.xml accordingly.

                     

                    The api jar goes in modules/javax/faces/api/main.  Again, update modules.xml.

                     

                    Also, remove the com.sun.faces.spi.AnnotationProvider config param so it uses the JBoss version of the annotation provider.

                     

                    Stan

                    • 8. Re: Servlet.service() for servlet Faces Servlet threw exception: java.lang.NullPointerException
                      manso Newbie

                      Stan Silvert wrote:

                       

                      Have you tried upgrading JSF within AS instead of bundling?

                       

                      The impl jar goes in modules/com/sun/jsf-impl/main.  Update modules.xml accordingly.

                       

                      The api jar goes in modules/javax/faces/api/main.  Again, update modules.xml.

                       

                      Also, remove the com.sun.faces.spi.AnnotationProvider config param so it uses the JBoss version of the annotation provider.

                       

                      Stan

                       

                      This approach doesn´t work. I tryed to update jars to jsf-impl-2.1.16-jbossorg-1.jar and jboss-jsf-api_2.1_spec-2.0.9.Final.jar, but it happened the same error described in http://stackoverflow.com/q/14500693/1868709.

                       

                      10:40:00,130 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.deployment.subunit."Prj.ear"."prjfrontend-1.0.0-SNAPSHOT.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."prjapp.ear"."prjfrontend-1.0.0-SNAPSHOT.war".POST_MODULE: Failed to process phase POST_MODULE of subdeployment "prjfrontend-1.0.0-SNAPSHOT.war" of deployment "prjapp.ear"
                        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
                        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) [rt.jar:1.6.0_07]
                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) [rt.jar:1.6.0_07]
                        at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_07]
                      Caused by: java.lang.NoClassDefFoundError: javax/faces/model/DataModel
                        at java.lang.Class.getDeclaredConstructors0(Native Method) [rt.jar:1.6.0_07]
                        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389) [rt.jar:1.6.0_07]
                        at java.lang.Class.getConstructor0(Class.java:2699) [rt.jar:1.6.0_07]
                        at java.lang.Class.getConstructor(Class.java:1657) [rt.jar:1.6.0_07]
                        at org.jboss.as.web.deployment.jsf.JsfManagedBeanProcessor.deploy(JsfManagedBeanProcessor.java:108)
                        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
                        ... 5 more
                      Caused by: java.lang.ClassNotFoundException: javax.faces.model.DataModel from [Module "deployment.prjapp.ear:main" from Service Module Loader]
                        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
                        at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
                        at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
                        at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
                        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
                        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
                        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) [rt.jar:1.6.0_07]
                        ... 11 more
                      
                      • 9. Re: Servlet.service() for servlet Faces Servlet threw exception: java.lang.NullPointerException
                        Nicklas Karlsson Master

                        Didn't try upgrading but I had a glance at the Mojarra 2.1.17 download and it looks like it bundles both the API and the impl in one jar (javax.faces.* and com.sun.faces.*). Wonder if this causes a conflict with the api jar when upgrading and how should the upgrade be done? Split up the jar manually into two?

                        • 10. Re: Servlet.service() for servlet Faces Servlet threw exception: java.lang.NullPointerException
                          manso Newbie

                          Sorry reopening this post, but I saw it still did not have correct answer. I don't know the cause, but it seems to be related to this post on StackOverflow and this JBoss issue.

                           

                          As a workaround (it works for me), you can use primefaces components, like <p:commandButton> or use <p:ajax> nested to a h:commandButton.

                           

                            <h:commandButton action="#{bean.method}" value="Test" >
                                 
                          <p:ajax process="@form" event="click" update="tblObject"/>
                           
                          </h:commandButton>

                           

                           


                          1 of 1 people found this helpful