问题描述
我正在尝试从"Core JavaServer Faces"书中运行示例ch05( http://horstmann.com /corejsf/)
I'm trying to run the example ch05 from the "Core JavaServer Faces" Book (http://horstmann.com/corejsf/)
登录后,我收到以下消息:
After logging in I get the following message:
/sections/planetarium/sidebarLeft.xhtml @12,72 <corejsf:planet> null
planet是一个组合,位于WEB-INF/tags/corejsf/planet.xhtml
planet is a composition, residing under WEB-INF/tags/corejsf/planet.xhtml
corejsf.taglib.xml是:
The corejsf.taglib.xml is:
<?xml version="1.0"?>
<!DOCTYPE facelet-taglib PUBLIC
"-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
"http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
<facelet-taglib>
<namespace>http://corejsf.com/facelets</namespace>
<tag>
<tag-name>planet</tag-name>
<source>tags/corejsf/planet.xhtml</source>
</tag>
</facelet-taglib>
web.xml包含文件:
The web.xml includes the file:
<context-param>
<param-name>facelets.LIBRARIES</param-name>
<param-value>/WEB-INF/corejsf.taglib.xml</param-value>
</context-param>
调试时,我在寻找"jndi:/server/planets/WEB-INF/tags/corejsf/planet.xhtml"时收到FileNotFoundException.
When debugging, I get a FileNotFoundException while looking for "jndi:/server/planets/WEB-INF/tags/corejsf/planet.xhtml".
在其他机器上,我进行了同样的战斗,也没有例外.
On other machines I deployed the same war and got no exception.
战争部署在GlassFish4上
The war is deployed on GlassFish4
最后是堆栈跟踪:
com.sun.faces.facelets.impl.DefaultFaceletCache._unwrapIOException(DefaultFaceletCache.java:166)
com.sun.faces.facelets.impl.DefaultFaceletCache.getFacelet(DefaultFaceletCache.java:126)
com.sun.faces.facelets.impl.DefaultFaceletCache.getFacelet(DefaultFaceletCache.java:63)
com.sun.faces.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:299)
com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:370)
com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:326)
com.sun.faces.facelets.tag.UserTagHandler.apply(UserTagHandler.java:142)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:190)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:189)
com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:87)
com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:312)
com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:371)
com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:350)
com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:199)
com.sun.faces.facelets.tag.ui.IncludeHandler.apply(IncludeHandler.java:120)
com.sun.faces.facelets.tag.ui.InsertHandler.apply(InsertHandler.java:116)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:190)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:87)
com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:312)
com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:371)
com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:350)
com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:199)
com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:169)
com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:87)
com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:161)
com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:972)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:99)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
推荐答案
我遇到了同样的问题,我的项目(Glassfish 4 + Spring + EJB 3 + JSF 2.2 + Custom Tags)在我的本地Glassfish和一个登台服务器,但是在生产环境中它抛出了异常TagException: /WEB-INF/templates/common.xhtml @38,33 <app:div> null
.
I was experiencing the same problem, my project (Glassfish 4 + Spring + EJB 3 + JSF 2.2 + Custom Tags) was running fine on my local Glassfish and on a staging server, but on Production it was throwing an exception TagException: /WEB-INF/templates/common.xhtml @38,33 <app:div> null
.
经过大量调试,我们发现了问题所在.如果您的Glassfish配置了多个虚拟服务器,并且已部署项目并将其与2个或更多虚拟机关联,那么JSF库会通过您正在访问的当前主机名读取源文件,但是对于读取的自定义facelets标签,一个不同的虚拟服务器(可能是一个错误)并抛出一个FileNotFoundException
(由抑制).
After a lot of debugging we found out the problem. If your Glassfish have more than one virtual server configured and your project is deployed and associated with 2 or more, the JSF lib reads the sources files through the current host name you are accessing it, however for custom facelets tags it reads through a different virtual server (probably a bug) and throws a FileNotFoundException
(suppressed by TagException
).
如果将部署的项目配置为仅一个虚拟服务器,则不会发生此问题.
If you configure your deployed project to only one virtual server, this problem does not occur.
这篇关于使用Facelets标记文件时出现FileNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!