title: JSF <ui:include /> Recursion Causes java.lang.StackOverflowError
body: <p>I have, what I would assume, is a pretty common use case.  We're rendering a simple "Comments" page using JSF on Wildfly 10.0.  Each comment may have a parent comment, and child comments underneath it.  Since there's no way to know ahead of time what the structure is, we'd like to create a JSF fragment and <code>&lt;ui:include /&gt;</code> it recursively to render the contents.  It would look something like this...</p>
  
  <p>Main page:</p>
  
  <pre><code>&lt;ul class="comments&gt;
    &lt;ui:repeat value="#{myObj.comments}" var="comment"&gt;
      &lt;ui:include src="/WEB-INF/fragments/comment.xhtml"&gt;
        &lt;ui:param name="comment" value="#{comment}" /&gt;
      &lt;/ui:include&gt;
    &lt;/ui:repeat&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Comment Fragment:</p>
  
  <pre><code>&lt;li&gt;&lt;h:outputText value="#{comment.text}"&gt;
    &lt;ui:fragment rendered="#{not empty comment.childComments}"&gt;
      &lt;ul class="comments"&gt;  
        &lt;ui:repeat value="#{comment.childComments}" var="comment"&gt;
          &lt;ui:include src="/WEB-INF/fragments/comment.xhtml"&gt;
            &lt;ui:param name="comment" value="#{comment}" /&gt;
          &lt;/ui:include&gt;
        &lt;/ui:repeat&gt;
      &lt;/ul&gt;
    &lt;/ui:fragment&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p>However, when I run this code, the recursion seems to cause  <code>java.lang.StackOverflowError</code>, regardless of how many items there are.  Additionally, we see a <code>javax.servlet.ServletException</code> saying, <code>"Could not Resolve Variable [Overflow]"</code></p>
  
  <p>Is there a reason why this recursive call results in this Exception?  Is there a better way to accomplish this?  I've tried using <code>&lt;c:forEach /&gt;</code> to iterate over the comments, however when I do this it does not appear to work in JSF.  I've tried both the <code>http://xmlns.jcp.org/jsp/jstl/core</code> and <code>http://java.sun.com/jsp/jstl/core</code> namespaces for the taglib, but the <code>&lt;c:forEach /&gt;</code> tag doesn't seem to iterate over my objects.  (That is, nothing is being rendered to the page)</p>
  
  <p>Any help you can give would be GREATLY appreciated.</p>