[ https://issues.apache.org/jira/browse/MYFACES-384?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12544890 ]
Adam Jenkins commented on MYFACES-384: -------------------------------------- What's the status of this issue. It seems there was a solution supplied quite some time ago, did it ever make it into any builds? Cheers Adam > Allow Pre-compiling web application for Tomcat > ---------------------------------------------- > > Key: MYFACES-384 > URL: https://issues.apache.org/jira/browse/MYFACES-384 > Project: MyFaces Core > Issue Type: Improvement > Components: General > Affects Versions: 1.0.9m9 > Environment: Tomcat -- Jasper2 > Reporter: John Schneider > Assignee: Manfred Geiler > Priority: Minor > > Pre-compiling web applications for Tomcat is not supported "out of the box" > as it should be. I have written a filter that performs essentially the same > function as FacesServlet, so that each individual JSP servlet can be defined > and mapped in web.xml. However, limitations in > myfaces.webapp.webxml.WebXml.getFacesServletMappings() prevents these mapped > servlets from rendering the view. > The code in question is: if > (FacesServlet.class.isAssignableFrom(servletClass)) { > This will prevent any pre-compiled page from being added as a faces servlet > mapping, as these servlets extend org.apache.jasper.runtime.HttpJspBase. > The applicable stack trace is as follows: > 14:02:45,443 DEBUG LifecycleImpl:118 - entering restoreView in > org.apache.myfaces > .lifecycle.LifecycleImpl > 14:02:45,637 DEBUG JspStateManagerImpl:196 - No serialized view found in > server s > ession! > 14:02:45,779 DEBUG JspViewHandlerImpl:191 - Created view /success.jsp > 14:02:45,914 DEBUG DebugUtils:158 - Newly created view > ======================================== > <UIViewRoot id="NULL" family="javax.faces.ViewRoot" locale="en" > renderKitId="HTML > _BASIC" rendered="true" rendererType="NULL" rendersChildren="false" > transient="fa > lse" viewId="/success.jsp"/> > ======================================== > 14:02:45,960 DEBUG LifecycleImpl:157 - exiting restoreView in > org.apache.myfaces. > lifecycle.LifecycleImpl (--> render response) > 14:02:45,963 DEBUG LifecycleImpl:288 - entering renderResponse in > org.apache.myfa > ces.lifecycle.LifecycleImpl > 14:02:45,981 DEBUG WebXmlParser:117 - ignoring servlet + > org.apache.jsp.success_j > sp class org.apache.jsp.success_jsp (no FacesServlet) > 14:02:45,985 ERROR JspViewHandlerImpl:424 - no faces servlet mappings found > 14:02:46,012 ERROR success_jsp]:253 - Servlet.service() for servlet > org.apache.js > p.success_jsp threw exception > java.lang.IllegalArgumentException: could not find pathMapping for > servletPath = > /success.jsf requestPathInfo = null > at > org.apache.myfaces.application.jsp.JspViewHandlerImpl.getServletMappin > g(JspViewHandlerImpl.java:425) > at > org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspVi > ewHandlerImpl.java:246) > at > org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:3 > 00) > at com.urban4life.web.util.FacesFilter.doFilter(FacesFilter.java:63) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appli > cationFilterChain.java:202) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFi > lterChain.java:173) > at > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVa > lve.java:213) > at > org.apache.catalina.core.StandardContextValve.invoke(StandardContextVa > lve.java:178) > at > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.ja > va:126) > at > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.ja > va:105) > at > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValv > e.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.proces > sConnection(Http11Protocol.java:744) > at > org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoi > nt.java:527) > at > org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFoll > owerWorkerThread.java:80) > at > org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPo > ol.java:684) > at java.lang.Thread.run(Thread.java:595) > ------------------------- > FacesFilter: > import java.io.IOException; > import javax.faces.FactoryFinder; > import javax.faces.context.FacesContext; > import javax.faces.context.FacesContextFactory; > import javax.faces.lifecycle.Lifecycle; > import javax.faces.lifecycle.LifecycleFactory; > import javax.servlet.Filter; > import javax.servlet.FilterChain; > import javax.servlet.FilterConfig; > import javax.servlet.ServletException; > import javax.servlet.ServletRequest; > import javax.servlet.ServletResponse; > import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; > /** > * @author <a href="mailto:[EMAIL PROTECTED]">John Schneider</a> > */ > public class FacesFilter implements Filter { > private Log logger = LogFactory.getLog(FacesFilter.class); > > public static final String LIFECYCLE_ID_ATTR = > "javax.faces.LIFECYCLE_ID"; > > private FilterConfig filterConfig; > private FacesContextFactory facesContextFactory; > private Lifecycle lifecycle; > private String getLifecycleId() { > String lifecycleId = > filterConfig.getServletContext().getInitParameter(LIFECYCLE_ID_ATTR); > return lifecycleId != null ? lifecycleId : > LifecycleFactory.DEFAULT_LIFECYCLE; > } > public void init(FilterConfig filterConfig) throws ServletException { > this.filterConfig = filterConfig; > this.facesContextFactory = > (FacesContextFactory)FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY); > LifecycleFactory lifecycleFactory = > (LifecycleFactory)FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY); > this.lifecycle = > lifecycleFactory.getLifecycle(getLifecycleId()); > logger.debug("Faces Filter Initialized"); > } > > public void doFilter(ServletRequest request, ServletResponse response, > FilterChain chain) > throws IOException, ServletException { > > FacesContext facesContext = facesContextFactory.getFacesContext( > filterConfig.getServletContext(), request, > response, lifecycle); > try { > lifecycle.execute(facesContext); > lifecycle.render(facesContext); > } > catch (Throwable e) { > logger.error(e); > if (e instanceof IOException) { > throw (IOException)e; > } > else if (e instanceof ServletException) { > throw (ServletException)e; > } > else if (e.getMessage() != null) { > throw new ServletException(e.getMessage(), e); > } > else { > throw new ServletException(e); > } > } > finally { > facesContext.release(); > } > } > > public void destroy() { > filterConfig = null; > facesContextFactory = null; > lifecycle = null; > } > } > ------------------------- > 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> > <!-- Faces Parameters --> > <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> > <!-- Faces Filter --> > <filter> > <filter-name>FacesFilter</filter-name> > <filter-class>com.mycompany.web.util.FacesFilter</filter-class> > </filter> > <filter-mapping> > <filter-name>FacesFilter</filter-name> > <url-pattern>*.jsf</url-pattern> > </filter-mapping> > </web-app> -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.