TagException ... null(File not found)创建自定义Facelets标签 [英] TagException ... null (File not found) on creating custom Facelets tag

查看:164
本文介绍了TagException ... null(File not found)创建自定义Facelets标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个基于JSF 2.2(Mojarra)的应用程序。我使用的是Eclipse EE生成的EAR项目和动态Web项目以及Glassfish服务器。



我创建了一个Facelet标记文件,如https://stackoverflow.com/a/5716633/2266635 。当我加载一个包含标签的页面时,我得到这个错误(和一个HTTP 500错误):

  2014-03-24T00: 32:10.904 + 0100警告:StandardWrapperValve [Faces Servlet]:servlet的Servlet.service()Faces Servlet抛出异常
javax.faces.view.facelets.TagException:/index.xhtml @ 19,19< fmk :登录形式> 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(FaceletViewHand lingStrategy.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)

我也尝试在上复制示例http://www.mkyong.com/jsf2/custom-tags-in-jsf-2-0/ ,我仍然收到错误(使用不同的标签)。

UserTagHandler.java第144行的错误是FileNotFoundException。如果我在taglib定义文件中提供一个无效文件为< source> ,我会得到相同的错误!所以它永远不会找到带有标签源代码的文件。

以下是文件树的截图: http://www.fa2k.net/misc/project.png (抱歉,不允许发布内嵌图片)



相关片段文件:

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.0encoding =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 /网络facelettaglibrary_2_2.xsd>
< namespace> http://famake.com/jsf/facelets< /命名空间>
< tag>
<标签名称>登录表单< /标签名称>
< source>标记/ 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/核心
xmlns:h =http://xmlns.jcp.org/jsf/html
xmlns:ui =http://xmlns.jcp.org/jsf/facelets>

测试标记

< / ui:composition>

index.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> JSF 2.0中的Custome标签< / h1>
< fmk:login-form />
< / h:body>
< / html>

我不明白为什么Glassfish找不到我的登录表单.xhtml 。我尝试过不同的路径,甚至尝试了strace'ing玻璃鱼,但没有任何明智的结果...任何想法可能是错的什么? 解决方案

问题出在服务器配置中。我找不到原因,但它在另一个Glassfish实例上工作,所以我刚刚删除了域并重新创建了它。对不起,我找不到更具体的东西。


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?

解决方案

The problem was in the server configuration. I couldn't find the cause, but it worked on a different Glassfish instance, so I just deleted the domain and re-created it. Sorry I couldn't find anything more specific.

这篇关于TagException ... null(File not found)创建自定义Facelets标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆