I am creating an application based on JSF 2.2 (Mojarra). I am using a Java EE EAR project and a Dynamic Web project generated by Eclipse, and the Glassfish server.
I created a Facelet tag file as shown in https://stackoverflow.com/a/5716633/2266635 . When I load a page containing the tag I get this error (and a HTTP 500 error):
2014-03-24T00:32:10.904+0100|WARNING: StandardWrapperValve[Faces Servlet]: Servlet.service() for servlet Faces Servlet threw exception
javax.faces.view.facelets.TagException: /index.xhtml @19,19 <fmk:login-form> null
at com.sun.faces.facelets.tag.UserTagHandler.apply(UserTagHandler.java:144)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:190)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:87)
at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:161)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:972)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:99)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
I have also tried to copy the example at http://www.mkyong.com/jsf2/custom-tags-in-jsf-2-0/ verbatim, and I'm still getting the error (with a different tag).
The error at line 144 of UserTagHandler.java is a FileNotFoundException. If I supply an invalid file as <source>
in the taglib definition file, I get the same error! So it never finds the file with the tag source code.
Here is a screenshot of the file tree: http://www.fa2k.net/misc/project.png (sorry, not allowed to post inline images yet)
Snippets from relevant files:
WEB-INF/web.xml
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/famake.taglib.xml</param-value>
</context-param>
WEB-INF/famake.taglib.xml
<?xml version="1.0" encoding="UTF-8"?>
<facelet-taglib version="2.2"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facelettaglibrary_2_2.xsd">
<namespace>http://famake.com/jsf/facelets</namespace>
<tag>
<tag-name>login-form</tag-name>
<source>tags/login-form.xhtml</source>
</tag>
</facelet-taglib>
WEB-INF/tags/login-form.xhtml
:
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
Test tag
</ui:composition>
index.xhtml
:
...
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:fmk="http://famake.com/jsf/facelets">
<h:body>
<h1>Custome Tags in JSF 2.0</h1>
<fmk:login-form/>
</h:body>
</html>
I don't understand why Glassfish can't find my login-form.xhtml
. I have tried different paths and even tried strace'ing glassfish, but without any sensible results... Any ideas what could be wrong?