Outcommented Facelets code still invokes EL expressions like #{bean.action()} and causes javax.el.PropertyNotFoundException on #{bean.action}

Look closer at the stack trace. Here’s the relevant part:

...
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
com.sun.faces.facelets.el.ELText$ELTextVariable.toString(ELText.java:217)
com.sun.faces.facelets.el.ELText$ELTextComposite.toString(ELText.java:157)
com.sun.faces.facelets.compiler.CommentInstruction.write(CommentInstruction.java:77)
...

It’s thus evaluating EL in a comment block (recognizable by CommentInstruction). A comment block is considered as template text. Facelets evaluates by default also EL #{} in template text. It’s like as if you’re writing <p>#{screenShotBean.takeScreenshot}</p> without any JSF tag.

You’ve several options:

  1. Remove the comment block altogether.

  2. Escape EL expressions in the comment by prefixing it with \ as in

    \#{screenShotBean.takeScreenshot}
    

    so that they won’t be evaluated.

  3. Wrap the entire comment block in <ui:remove> so that it doesn’t appear in the component tree (nor in the generated HTML output).

  4. Disable parsing of all comments by Facelets by adding the following context parameter to web.xml:

    <context-param>
        <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
        <param-value>true</param-value>
    </context-param>
    

    Note that no one comment will end up in generated HTML output this way.

Leave a Comment