FileNotFoundException when using Facelets tagfile

690 views Asked by At

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 is a composition, residing under WEB-INF/tags/corejsf/planet.xhtml

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>

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>

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.

The war is deployed on GlassFish4

At last the stack trace:

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)
1

There are 1 answers

0
Hugo Baés On

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.

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.