1

我正在尝试运行“Core JavaServer Faces”书(http://horstmann.com/corejsf/)中的示例 ch05

登录后,我收到以下消息:

/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)
4

1 回答 1

2

我遇到了同样的问题,我的项目(Glassfish 4 + Spring + EJB 3 + JSF 2.2 + Custom Tags)在我的本地 Glassfish 和登台服务器上运行良好,但在生产上却抛出了异常TagException: /WEB-INF/templates/common.xhtml @38,33 <app:div> null

经过大量调试,我们发现了问题所在。如果您的 Glassfish 配置了多个虚拟服务器,并且您的项目已部署并与 2 个或更多相关联,则 JSF lib 通过您正在访问它的当前主机名读取源文件,但是对于自定义 facelets 标签,它通过不同的虚拟服务器(可能是一个错误)并抛出一个FileNotFoundException(被 抑制TagException)。

如果您将部署的项目配置为仅一台虚拟服务器,则不会出现此问题。

于 2014-09-12T12:04:02.893 回答