Note that there are some explanatory texts on larger screens.

plurals
  1. PO"Tag not found" exception when first navigating to page
    primarykey
    data
    text
    <p>I encountered the following problem in our application: After each server restart or redeployment of the application the first attempt to navigate to one specific page will fail with an exception:</p> <pre><code>javax.faces.view.facelets.TagException: /testing/target.xhtml @8,72 &lt;ofc:testComp&gt; Tag Library supports namespace: http://java.sun.com/jsf/composite/of-components, but no tag was defined for name: testComp </code></pre> <p>I laboured a while to strip this down to a minimal version. In doing so I figured out the following:</p> <p>The problem occurs when:</p> <ul> <li>The server has been restarted or the application redeployed</li> <li>One tries to navigate to a certain page through an <code>h:commandLink</code></li> <li>The target page uses a composite component</li> </ul> <p>The problem goes away when:</p> <ul> <li>one reaches the target page in some other way, e.g. through an <code>h:outputLink</code> or via URL</li> <li>ever after the target page has been successfully reached once</li> </ul> <p>I ruled out all kinds of things (we're on Mojarra 2.1.7 and the target page does not nest components, so it's not this problem with <a href="https://stackoverflow.com/q/10898906/840977">nested namespace declarations</a>) and narrowed it down to the following "culprit": </p> <p>The source page uses a template, which I simplified as follows:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"&gt; &lt;h:head&gt; &lt;title&gt;Testpage&lt;/title&gt; &lt;/h:head&gt; &lt;h:body&gt; &lt;h:form id="form"&gt; &lt;ui:insert name="content"/&gt; &lt;ui:include src="some_other_content.xhtml" /&gt; &lt;/h:form&gt; &lt;/h:body&gt; &lt;/html&gt; </code></pre> <p>If I remove the <code>ui:include</code> everything works. Can somebody explain to me what is happening here? It seems to have something to do with initializing my component library after a server restart, but I don't get how the include in the template has to do with it. As far as I know this is the standard way to include some fixed content to a page? If this is not how it should be done, please let me know what other ways there are.</p> <p>Thanks!</p> <hr> <hr> <p><strong>Remaining code snippets for completeness</strong> (no magic happening here):</p> <p><strong>source_page.xhtml</strong></p> <pre><code>&lt;ui:composition template="/testing/test_template.xhtml"&gt; &lt;ui:define name="content"&gt; &lt;h:outputLink value="target.xhtml"&gt;Outputlink to target&lt;/h:outputLink&gt; &lt;br /&gt; &lt;h:commandLink value="Commandlink to target" action="target.xhtml" /&gt; &lt;/ui:define&gt; &lt;/ui:composition&gt; </code></pre> <p><strong>target.xhtml</strong></p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:ofc="http://java.sun.com/jsf/composite/of-components" xmlns:h="http://java.sun.com/jsf/html"&gt; &lt;h:head&gt;&lt;/h:head&gt; &lt;h:body&gt; &lt;ofc:testComp content="This is a component for testing purposes" /&gt; &lt;/h:body&gt; &lt;/html&gt; </code></pre> <p><strong>testComp.xhtml</strong></p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:cc="http://java.sun.com/jsf/composite"&gt; &lt;cc:interface&gt; &lt;cc:attribute name="content" required="true" /&gt; &lt;/cc:interface&gt; &lt;cc:implementation&gt; &lt;h:outputText value="#{cc.attrs.content}" /&gt; &lt;/cc:implementation&gt; &lt;/html&gt; </code></pre> <p>And finally, <strong>some_other_content.xhtml</strong> is just a random Hello-World-Page.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload