You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by John Schneider <js...@jschneider.com> on 2005/08/02 21:31:03 UTC

Run-time exception from precompiled pages

I have set up precompilation of a myfaces web app according to the 
instructions found at 
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jasper-howto.html

Precompilation completes successfully.  There are no errors; only a warning 
about not being able to initialize Log4J.

Not precompiling things, everything works fine.  However, when I precompile, I 
get a NullPointerException when the servlet tries to render the f:view.  
Please review the relevent information below, and help me figure out what I 
am doing wrong!

Thanks,

John Schneider


----- web.xml ------

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
    xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <servlet>
        <servlet-name>org.apache.jsp.success_jsp</servlet-name>
        <servlet-class>org.apache.jsp.success_jsp</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>org.apache.jsp.success_jsp</servlet-name>
        <url-pattern>/success.jsf</url-pattern>
    </servlet-mapping>
    <context-param>
        <param-name>javax.faces.CONFIG_FILES</param-name>
        
<param-value>/WEB-INF/faces-config.xml,/WEB-INF/faces-managed-beans.xml,/WEB-INF/faces-navigation.xml</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>server</param-value>
    </context-param>
    <!-- Listener, that does all the startup work (configuration, init). -->
    <listener>
   
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
    </listener>
</web-app>


----- success.jsp ------

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<html>
  <head>
  <title>Success Page</title>
</head>      
<body>
  <f:view>
  <h:outputText value="success"/>
  </f:view>
</body> 
</html> 


----- And here is the Error ------

15:20:26,099  INFO FacesConfigurator:226 - Reading standard config 
org/apache/myfaces/resource/standard-faces-config.xml
15:20:31,016  INFO FacesConfigurator:385 - Reading config 
jar:file:/var/tmp/myfaces57459.jar!/META-INF/faces-config.xml
15:20:34,835  INFO FacesConfigurator:385 - Reading config 
jar:file:/var/tmp/myfaces57460.jar!/META-INF/faces-config.xml
15:20:35,044  INFO FacesConfigurator:420 - Reading 
config /WEB-INF/faces-config.xml
15:20:35,124  INFO FacesConfigurator:420 - Reading 
config /WEB-INF/faces-managed-beans.xml
15:20:35,352  INFO FacesConfigurator:420 - Reading 
config /WEB-INF/faces-navigation.xml
15:20:35,511  INFO FacesConfigurator:435 - Reading 
config /WEB-INF/faces-config.xml
15:20:41,497  INFO StartupServletContextListener:122 - ServletContext 
'/usr/local/jakarta-tomcat5.5/webapps/urban4life.com-0.1-dev/' initialized.
15:21:38,933 ERROR success_jsp]:260 - Servlet.service() for servlet 
org.apache.jsp.success_jsp threw exception
java.lang.NullPointerException
        at 
javax.faces.webapp.UIComponentTag.setupResponseWriter(UIComponentTag.java:646)
        at 
javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:254)
        at org.apache.myfaces.taglib.core.ViewTag.doStartTag(ViewTag.java:90)
        at org.apache.jsp.success_jsp._jspx_meth_f_view_0(success_jsp.java:79)
        at org.apache.jsp.success_jsp._jspService(success_jsp.java:56)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
        at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
        at 
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at 
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
        at 
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
        at java.lang.Thread.run(Thread.java:595)

Re: Run-time exception from precompiled pages

Posted by John Schneider <js...@jschneider.com>.
I thought that might be the problem.  Thanks for confirming my vague 
suspicion.  This morning, I wrote my own filter based on FacesServlet.  I am 
pretty sure it would work if it weren't for limitations in myfaces code.

When I invoke javax.faces.lifecycle.Lifecycle.render(facesContext), 
org.apache.myfaces.application.jsp.JspViewHandlerImpl.getServletMapping() 
invokes org.apache.myfaces.webapp.webxml.WebXml.getFacesServletMappings(), 
which adds servlet mapping entries from web.xml.  The problem is, it checks 
to see whether my JSP page is a FacesServlet. If it's not, the mapping does 
not get added to the list.  This is bullshit; I'm submitting a bug report, 
and a request to provide a "FacesFilter" for use with precompiled web-apps.  
We would probably also need some kind of context param to indicate that we 
are using precompiled pages.

Has no one ever tried to precompile a MyFaces webapp?  Is their a workaround 
for this?

Lines 103-118 of WebXml:
if (FacesServlet.class.isAssignableFrom(servletClass))
            {
                List urlPatterns = (List)_servletMappings.get(servletName);
                for (Iterator it2 = urlPatterns.iterator(); it2.hasNext(); )
                {
                    String urlpattern = (String)it2.next();
                    _facesServletMappings.add(new ServletMapping(servletName,
                                                                 servletClass,
                                                                 urlpattern));
                if (log.isTraceEnabled())
                    log.trace("adding mapping for servlet + " + servletName + 
" urlpattern = " + urlpattern);                    }
            }
            else
            {
                if (log.isTraceEnabled()) log.trace("ignoring servlet + " + 
servletName + " " + servletClass + " (no FacesServlet)");
            }

Maybe we could change it to something like:
if (FacesServlet.class.isAssignableFrom(servletClass) || precompiling) {

where precompiling is a switch set by a context parm.

Regards,

John Schneider


On Wednesday 03 August 2005 05:03, Mathias Broekelmann wrote:
> It´s because the facesservlet doesn´t handle the request.
>
> You should be able to create a servlet filter which contains the code of
> the facesservlet to initialize the stuff and process the jsf request.
>
> Hope that´s helps a little bit.
>
> Regards,
> Mathias
>
> John Schneider schrieb:
> > I have set up precompilation of a myfaces web app according to the
> > instructions found at
> > http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jasper-howto.html
> >
> > Precompilation completes successfully.  There are no errors; only a
> > warning about not being able to initialize Log4J.
> >
> > Not precompiling things, everything works fine.  However, when I
> > precompile, I get a NullPointerException when the servlet tries to render
> > the f:view. Please review the relevent information below, and help me
> > figure out what I am doing wrong!
> >
> > Thanks,
> >
> > John Schneider
> >
> >
> > ----- web.xml ------
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <web-app version="2.4"
> >     xmlns="http://java.sun.com/xml/ns/j2ee"
> >     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> > http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
> >
> >     <servlet>
> >         <servlet-name>org.apache.jsp.success_jsp</servlet-name>
> >         <servlet-class>org.apache.jsp.success_jsp</servlet-class>
> >     </servlet>
> >     <servlet-mapping>
> >     <servlet-name>org.apache.jsp.success_jsp</servlet-name>
> >         <url-pattern>/success.jsf</url-pattern>
> >     </servlet-mapping>
> >     <context-param>
> >         <param-name>javax.faces.CONFIG_FILES</param-name>
> >
> > <param-value>/WEB-INF/faces-config.xml,/WEB-INF/faces-managed-beans.xml,/
> >WEB-INF/faces-navigation.xml</param-value> </context-param>
> >     <context-param>
> >         <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
> >         <param-value>server</param-value>
> >     </context-param>
> >     <!-- Listener, that does all the startup work (configuration, init).
> > --> <listener>
> >
> > <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</
> >listener-class> </listener>
> > </web-app>
> >
> >
> > ----- success.jsp ------
> >
> > <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
> > <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
> > <html>
> >   <head>
> >   <title>Success Page</title>
> > </head>
> > <body>
> >   <f:view>
> >   <h:outputText value="success"/>
> >   </f:view>
> > </body>
> > </html>
> >
> >
> > ----- And here is the Error ------
> >
> > 15:20:26,099  INFO FacesConfigurator:226 - Reading standard config
> > org/apache/myfaces/resource/standard-faces-config.xml
> > 15:20:31,016  INFO FacesConfigurator:385 - Reading config
> > jar:file:/var/tmp/myfaces57459.jar!/META-INF/faces-config.xml
> > 15:20:34,835  INFO FacesConfigurator:385 - Reading config
> > jar:file:/var/tmp/myfaces57460.jar!/META-INF/faces-config.xml
> > 15:20:35,044  INFO FacesConfigurator:420 - Reading
> > config /WEB-INF/faces-config.xml
> > 15:20:35,124  INFO FacesConfigurator:420 - Reading
> > config /WEB-INF/faces-managed-beans.xml
> > 15:20:35,352  INFO FacesConfigurator:420 - Reading
> > config /WEB-INF/faces-navigation.xml
> > 15:20:35,511  INFO FacesConfigurator:435 - Reading
> > config /WEB-INF/faces-config.xml
> > 15:20:41,497  INFO StartupServletContextListener:122 - ServletContext
> > '/usr/local/jakarta-tomcat5.5/webapps/urban4life.com-0.1-dev/'
> > initialized. 15:21:38,933 ERROR success_jsp]:260 - Servlet.service() for
> > servlet org.apache.jsp.success_jsp threw exception
> > java.lang.NullPointerException
> >         at
> > javax.faces.webapp.UIComponentTag.setupResponseWriter(UIComponentTag.java
> >:646) at
> > javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:254)
> >         at
> > org.apache.myfaces.taglib.core.ViewTag.doStartTag(ViewTag.java:90) at
> > org.apache.jsp.success_jsp._jspx_meth_f_view_0(success_jsp.java:79) at
> > org.apache.jsp.success_jsp._jspService(success_jsp.java:56) at
> > org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) at
> > javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at
> > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicat
> >ionFilterChain.java:252) at
> > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilte
> >rChain.java:173) at
> > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve
> >.java:213) at
> > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve
> >.java:178) at
> > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
> >126) at
> > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
> >105) at
> > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.j
> >ava:107) at
> > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:14
> >8) at
> > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856
> >) at
> > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processCo
> >nnection(Http11Protocol.java:744) at
> > org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.
> >java:527) at
> > org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowe
> >rWorkerThread.java:80) at
> > org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.
> >java:684) at java.lang.Thread.run(Thread.java:595)

Re: Run-time exception from precompiled pages

Posted by Mathias Broekelmann <mb...@PSI.DE>.
It´s because the facesservlet doesn´t handle the request.

You should be able to create a servlet filter which contains the code of
the facesservlet to initialize the stuff and process the jsf request.

Hope that´s helps a little bit.

Regards,
Mathias

John Schneider schrieb:
> I have set up precompilation of a myfaces web app according to the 
> instructions found at 
> http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jasper-howto.html
> 
> Precompilation completes successfully.  There are no errors; only a warning 
> about not being able to initialize Log4J.
> 
> Not precompiling things, everything works fine.  However, when I precompile, I 
> get a NullPointerException when the servlet tries to render the f:view.  
> Please review the relevent information below, and help me figure out what I 
> am doing wrong!
> 
> Thanks,
> 
> John Schneider
> 
> 
> ----- web.xml ------
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app version="2.4"
>     xmlns="http://java.sun.com/xml/ns/j2ee"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
> 
>     <servlet>
>         <servlet-name>org.apache.jsp.success_jsp</servlet-name>
>         <servlet-class>org.apache.jsp.success_jsp</servlet-class>
>     </servlet>
>     <servlet-mapping>
>     <servlet-name>org.apache.jsp.success_jsp</servlet-name>
>         <url-pattern>/success.jsf</url-pattern>
>     </servlet-mapping>
>     <context-param>
>         <param-name>javax.faces.CONFIG_FILES</param-name>
>         
> <param-value>/WEB-INF/faces-config.xml,/WEB-INF/faces-managed-beans.xml,/WEB-INF/faces-navigation.xml</param-value>
>     </context-param>
>     <context-param>
>         <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
>         <param-value>server</param-value>
>     </context-param>
>     <!-- Listener, that does all the startup work (configuration, init). -->
>     <listener>
>    
> <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
>     </listener>
> </web-app>
> 
> 
> ----- success.jsp ------
> 
> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
> <html>
>   <head>
>   <title>Success Page</title>
> </head>      
> <body>
>   <f:view>
>   <h:outputText value="success"/>
>   </f:view>
> </body> 
> </html> 
> 
> 
> ----- And here is the Error ------
> 
> 15:20:26,099  INFO FacesConfigurator:226 - Reading standard config 
> org/apache/myfaces/resource/standard-faces-config.xml
> 15:20:31,016  INFO FacesConfigurator:385 - Reading config 
> jar:file:/var/tmp/myfaces57459.jar!/META-INF/faces-config.xml
> 15:20:34,835  INFO FacesConfigurator:385 - Reading config 
> jar:file:/var/tmp/myfaces57460.jar!/META-INF/faces-config.xml
> 15:20:35,044  INFO FacesConfigurator:420 - Reading 
> config /WEB-INF/faces-config.xml
> 15:20:35,124  INFO FacesConfigurator:420 - Reading 
> config /WEB-INF/faces-managed-beans.xml
> 15:20:35,352  INFO FacesConfigurator:420 - Reading 
> config /WEB-INF/faces-navigation.xml
> 15:20:35,511  INFO FacesConfigurator:435 - Reading 
> config /WEB-INF/faces-config.xml
> 15:20:41,497  INFO StartupServletContextListener:122 - ServletContext 
> '/usr/local/jakarta-tomcat5.5/webapps/urban4life.com-0.1-dev/' initialized.
> 15:21:38,933 ERROR success_jsp]:260 - Servlet.service() for servlet 
> org.apache.jsp.success_jsp threw exception
> java.lang.NullPointerException
>         at 
> javax.faces.webapp.UIComponentTag.setupResponseWriter(UIComponentTag.java:646)
>         at 
> javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:254)
>         at org.apache.myfaces.taglib.core.ViewTag.doStartTag(ViewTag.java:90)
>         at org.apache.jsp.success_jsp._jspx_meth_f_view_0(success_jsp.java:79)
>         at org.apache.jsp.success_jsp._jspService(success_jsp.java:56)
>         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>         at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
>         at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
>         at 
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
>         at 
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
>         at 
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
>         at 
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
>         at 
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
>         at 
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
>         at 
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
>         at 
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
>         at 
> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
>         at 
> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
>         at 
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
>         at java.lang.Thread.run(Thread.java:595)