5 Replies Latest reply on May 29, 2010 3:36 AM by Harsh Gidra

    Cannot find FacesContext - Glassfish Server

    Zaheer Ahmed Novice

      Hi all

      I'm having a strange problem after installing Glassfish Server. I've done most of my project using Tomcat and now changed it to glassfish.  The problem is when I'm sending a post request to Servlet page from JSF/JSP page I'm getting following error;

       

      org.apache.jasper.JasperException: java.lang.RuntimeException: Cannot find FacesContext

       

      root cause

      java.lang.RuntimeException: Cannot find FacesContext

      Has anyone got any ideas ??????????????

      Thanks
      Zed
        • 1. Re: Cannot find FacesContext - Glassfish Server
          Nick Belaevski Master

          Hi Zaheer,

           

          FacesContext is only available from the requests that were passed through FacesServlet. Please post exception stack trace.

          • 2. Re: Cannot find FacesContext - Glassfish Server
            Zaheer Ahmed Novice

            Thanks Nick for your reply here is full exception stack trace.

             

            java.lang.RuntimeException: Cannot find FacesContext
            at javax.faces.webapp.UIComponentClassicTagBase.getFacesContext(UIComponentClassicTagBase.java:1855)
            at javax.faces.webapp.UIComponentClassicTagBase.setJspId(UIComponentClassicTagBase.java:1672)
            at org.apache.jsp.myOffice_jsp._jspx_meth_f_view_0(myOffice_jsp.java from :220)
            at org.apache.jsp.myOffice_jsp._jspService(myOffice_jsp.java from :179)
            at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:109)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:406)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:483)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:373)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
            at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
            at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
            at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
            at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
            at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
            at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
            at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
            at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
            at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
            at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
            at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
            at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
            at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
            at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
            at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
            at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
            at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
            at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
            at java.lang.Thread.run(Thread.java:619)
            |#]

             

            Zed

            • 3. Re: Cannot find FacesContext - Glassfish Server
              Nick Belaevski Master

              There's no FacesServlet in the stack, check its mapping and page address.

              1 of 1 people found this helpful
              • 4. Re: Cannot find FacesContext - Glassfish Server
                Zaheer Ahmed Novice

                Thanks Nick I had to modify my web.xml like so;

                 

                Before

                 

                <servlet-mapping>
                    <servlet-name>eveAddProcess</servlet-name>
                    <url-pattern>/eveAddProcess</url-pattern>
                  </servlet-mapping>

                 

                After

                 

                <servlet-mapping>
                    <servlet-name>eveAddProcess</servlet-name>
                    <url-pattern>/faces/eveAddProcess</url-pattern>
                  </servlet-mapping>

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                • 5. Re: Cannot find FacesContext - Glassfish Server
                  Harsh Gidra Newbie

                  Even I am getting the same error:

                  An exception occurred processing JSP page /Hello.jsp at line 6 3: 4: 5: <html> 6: <f:view> 7: <head> 8: <title>Validating JSF Page</title> 9: </head> Stacktrace:

                   

                  Caused by:
                  java.lang.RuntimeException - Cannot find FacesContext

                   

                  Stack Trace:

                  javax.faces.FacesException: An exception occurred processing JSP page /Hello.jsp at line 6
                  
                  3: 
                  4: 
                  5:     <html>
                  6: <f:view>
                  7:     <head>
                  8:     <title>Validating JSF Page</title>
                  9:     </head>
                  
                  
                  Stacktrace:
                       at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:347)
                       at org.apache.myfaces.application.jsp.JspViewHandlerImpl.buildView(JspViewHandlerImpl.java:486)
                       at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:337)
                       at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
                       at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:140)
                       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:182)
                       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                       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:235)
                       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
                       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
                       at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
                       at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
                       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
                       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
                       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
                       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
                       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                       at java.lang.Thread.run(Thread.java:619)
                  Caused by: org.apache.jasper.JasperException: An exception occurred processing JSP page /Hello.jsp at line 6
                  
                  3: 
                  4: 
                  5:     <html>
                  6: <f:view>
                  7:     <head>
                  8:     <title>Validating JSF Page</title>
                  9:     </head>
                  
                  
                  Stacktrace:
                       at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:498)
                       at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)
                       at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
                       at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
                       at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                       at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638)
                       at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:444)
                       at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:382)
                       at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:310)
                       at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:341)
                       ... 25 more
                  Caused by: java.lang.RuntimeException: Cannot find FacesContext
                       at javax.faces.webapp.UIComponentClassicTagBase.getFacesContext(UIComponentClassicTagBase.java:1855)
                       at javax.faces.webapp.UIComponentClassicTagBase.setJspId(UIComponentClassicTagBase.java:1672)
                       at org.apache.jsp.Hello_jsp._jspx_meth_f_005fview_005f0(Hello_jsp.java:90)
                       at org.apache.jsp.Hello_jsp._jspService(Hello_jsp.java:65)
                       at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
                       at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                       at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
                       ... 35 more