Hello deras, I have a hands-on experience with JSF. I have been able to develop a first application. And I'm now in the stage of reorganizing it for a better management. I'm trying to move 'templates' to classpath in order to share them in jar for different applications. But I'm stack there. Pages that reference that template are not rendered and MyFaces returns the error (see below for full details of the error): java.io.FileNotFoundException: /lab-jsf-rsrcmng/javax.faces.resource/templateInClasspath.xhtml.xhtml?ln=mytempl Not Found in ExternalContext as a Resource
Please help in pointing the missing part in my application. *1) Project:* *1.1) Hierarchy* lab-jsf-rsrcmng * pom.xml* src/main/webapp * home2.xhtml* WEB-INF * faces-config.xml* * web.xml* src/main/resources/META-INF/resources/mytempl * templateInClasspath.xhtml* * * *1.2) pom.xml* <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd " > <modelVersion>4.0.0</modelVersion> <groupId>lab-jsf</groupId> <artifactId>lab-jsf-rsrcmng</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>LAB::JSF::RESOURCE MANAGEMENT</name> <url>http://maven.apache.org</url> <properties> <servlet.version>2.5</servlet.version> <jsp.version>2.1</jsp.version> <myfaces.version>2.0.3</myfaces.version> </properties> <dependencies> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>${servlet.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>${jsp.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.myfaces.core</groupId> <artifactId>myfaces-api</artifactId> <version>${myfaces.version}</version> </dependency> <dependency> <groupId>org.apache.myfaces.core</groupId> <artifactId>myfaces-impl</artifactId> <version>${myfaces.version}</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.2</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> </plugins> <finalName>${project.artifactId}</finalName> </build> </project> *1.3) home2.xhtml* <?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" > <h:body> <ui:composition template="#{resource['mytempl:templateInClasspath.xhtml']}"> </ui:composition> </h:body> </html> *1.4) 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_0.xsd " version="2.0" > </faces-config> *1.5) 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>lab-jsf-rsrcmng</display-name> <session-config> <session-timeout>30</session-timeout> </session-config> <welcome-file-list> <welcome-file>home2.xhtml</welcome-file> </welcome-file-list> <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>/faces/*</url-pattern> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> <context-param> <description> If true, a javascript function will be rendered that is able to restore the former vertical scroll on every request. Convenient feature if you have pages with long lists and you do not want the browser page to always jump to the top if you trigger a link or button action that stays on the same page. Default is 'false' </description> <param-name>org.apache.myfaces.AUTO_SCROLL</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>org.apache.myfaces.USE_ENCRYPTION</param-name> <param-value>false</param-value> </context-param> </web-app> *1.6) templateInClasspath.xhtml* <!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:c="http://java.sun.com/jsp/jstl/core" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" > <f:view contentType="text/html"> <h:head> <title>LAB::JSF::RSRCMNG</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </h:head> <h:body styleClass="natisoft-body" > <h:panelGrid columns="1"> <f:facet name="header"> <ui:insert name="header">Header</ui:insert> </f:facet> <f:facet name="footer"> <ui:insert name="trailer">Trailer</ui:insert> </f:facet> <h:panelGroup> <ui:insert name="content">Content</ui:insert> </h:panelGroup> </h:panelGrid> </h:body> </f:view> </html> *2) Error details* An Error Occurred: java.io.FileNotFoundException: /lab-jsf-rsrcmng/javax.faces.resource/templateInClasspath.xhtml.xhtml?ln=mytempl Not Found in ExternalContext as a Resource Caused by: java.io.FileNotFoundException - /lab-jsf-rsrcmng/javax.faces.resource/templateInClasspath.xhtml.xhtml?ln=mytempl Not Found in ExternalContext as a Resource - Stack Trace <http://localhost:17080/lab-jsf-rsrcmng/home2.xhtml#> javax.faces.FacesException: java.io.FileNotFoundException: /lab-jsf-rsrcmng/javax.faces.resource/templateInClasspath.xhtml.xhtml?ln=mytempl Not Found in ExternalContext as a Resource at org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.wrap(ExceptionHandlerImpl.java:241) at org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:156) at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:258) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:191) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:558) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:379) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:259) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:281) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) Caused by: java.io.FileNotFoundException: /lab-jsf-rsrcmng/javax.faces.resource/templateInClasspath.xhtml.xhtml?ln=mytempl Not Found in ExternalContext as a Resource at org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory.resolveURL(DefaultFaceletFactory.java:199) at org.apache.myfaces.view.facelets.impl.DefaultFacelet.getRelativePath(DefaultFacelet.java:289) at org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:346) at org.apache.myfaces.view.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:215) at org.apache.myfaces.view.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:140) at org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:57) at org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:45) at org.apache.myfaces.view.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:143) at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.buildView(FaceletViewDeclarationLanguage.java:329) at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:66) at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:239) ... 16 more - Component Tree <http://localhost:17080/lab-jsf-rsrcmng/home2.xhtml#> <UIViewRoot id="j_id0" inView="true" locale="en_US" renderKitId="HTML_BASIC" rendered="true" transient="false" viewId="/home2.xhtml"/> - State size:548 bytes - Scoped Variables <http://localhost:17080/lab-jsf-rsrcmng/home2.xhtml#> Request ParametersNameValue*None*Request AttributesNameValue*None*View AttributesNameValue*None*Flash AttributesNameValue*None*Application AttributesNameValue*None* Feb 19, 2011 9:52:09 AM - Generated by MyFaces - for information on disabling or modifying this error-page, see Disabling error handling in MyFaces <http://wiki.apache.org/myfaces/Handling_Server_Errors> Thank you in advance Younes Ouadi