我正在尝试从“Core JavaServer Faces”一书中运行示例ch05(http://horstmann.com/corejsf/)
登录后,我收到以下消息:
/sections/planetarium/sidebarLeft.xhtml @12,72 <corejsf:planet> null
planet是一个组成,驻留在WEB-INF / tags / corejsf / planet.xhtml下
corejsf.taglib.xml是:
<?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包含文件:
<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。
在其他机器上,我部署了相同的战争并且没有例外。
战争部署在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)
答案 0 :(得分:2)
我遇到了同样的问题,我的项目(Glassfish 4 + Spring + EJB 3 + JSF 2.2 +自定义标签)在我的本地Glassfish和登台服务器上正常运行,但在生产时它抛出异常{{ 1}}。
经过大量调试后我们发现了问题。如果您的Glassfish配置了多个虚拟服务器并且您的项目已部署并与2个或更多相关联,则JSF lib将通过您正在访问它的当前主机名读取源文件,但是对于自定义facelets标记它会通读一个不同的虚拟服务器(可能是一个bug)并抛出TagException: /WEB-INF/templates/common.xhtml @38,33 <app:div> null
(由FileNotFoundException
压制)。
如果将已部署的项目配置为仅一个虚拟服务器,则不会发生此问题。