Skip to main content

JSF2 parses EL expressions that are commented

4 replies [Last post]
vesuvius
Offline
Joined: 2007-06-02

Hi,

I have a page that looks roughly like the following:

<br />
<?xml version='1.0' encoding='UTF-8' ?></p>
<p>        Main</p>
<p>

I know the page is useless but I intentionally created it like this, so as not to clutter the example.

Please, pay attention to the fact that the EL expression is in a section that's commented out. So, it should not be evaluated.

When I try to display the page, however, I get an exception:

<br />
An Error Occurred:<br />
The class 'com.testapp.web.SomeBackingBean_$$_javassist_55' does not have the property 'logout'.</p>
<p>javax.el.PropertyNotFoundException: The class 'com.testapp.web.SomeBackingBean_$$_javassist_55' does not have the property 'logout'.<br />
	at javax.el.BeanELResolver.getBeanProperty(BeanELResolver.java:661)<br />
	at javax.el.BeanELResolver.getValue(BeanELResolver.java:290)<br />
	at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175)<br />
	at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)<br />
	at com.sun.el.parser.AstValue.getValue(AstValue.java:116)<br />
	at com.sun.el.parser.AstValue.getValue(AstValue.java:163)<br />
	at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219)<br />
	at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:71)<br />
	at com.sun.faces.facelets.el.ELText$ELTextVariable.toString(ELText.java:207)<br />
	at com.sun.faces.facelets.el.ELText$ELTextComposite.toString(ELText.java:148)<br />
	at com.sun.faces.facelets.compiler.CommentInstruction.write(CommentInstruction.java:70)<br />
	at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:75)<br />
	at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:176)<br />
	at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)<br />
	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)<br />
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613)<br />
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)<br />
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)<br />
	at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:380)<br />
	at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)<br />
	at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)<br />
	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)<br />
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)<br />
	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)<br />
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)<br />
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)<br />
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)<br />
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)<br />
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)<br />
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)<br />
	at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)<br />
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)<br />
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)<br />
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)<br />
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)<br />
	at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)<br />
	at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)<br />
	at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)<br />
	at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)<br />
	at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)<br />
	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)<br />
	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)<br />
	at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)<br />
	at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)<br />
	at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)<br />
	at com.sun.grizzly.ContextTask.run(ContextTask.java:69)<br />
	at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)<br />
	at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)<br />
	at java.lang.Thread.run(Thread.java:619)<br />

So, why does JSF attempt to evaluate EL expressions that are in comments?

Furthermore, the backing bean DOES have a logout method. And if I uncomment the code, it works. No exceptions. The property exists.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vesuvius
Offline
Joined: 2007-06-02

Thank you, guys! You've been extremely helpful. I appreciate this very much.

Just to clear things up a bit -- we've been using ADF Faces until recently. We were using JSPs (the default in JDeveloper 10.1.3.x). Comments there were placed inside

tags. That's why I assumed that it would be the same in facelets.

Ryan Lubke

is not considered a 'comment' by the compiler (this is true for
Facelets 1.1.x).

Instead, using your example, the entire line is considered an output
component with a value that contains
an expression (i.e. the comment will be passed to the browser).

In order to have the compiler ignore a fragment of the template, use
ui:remove.

On 2/25/10 8:20 AM, webtier@javadesktop.org wrote:
> Hi,
>
> I have a page that looks roughly like the following:
>
> [code]
>
>
> > xmlns:h="http://java.sun.com/jsf/html"
> xmlns:f="http://java.sun.com/jsf/core">
>
> Main
>

>
>
>

>
>
>
> [/code]
>
> I know the page is useless but I intentionally created it like this, so as not to clutter the example.
>
> Please, pay attention to the fact that the EL expression is in a section that's commented out. So, it should not be evaluated.
>
> When I try to display the page, however, I get an exception:
>
> [code]
> An Error Occurred:
> The class 'com.testapp.web.SomeBackingBean_$$_javassist_55' does not have the property 'logout'.
>
> javax.el.PropertyNotFoundException: The class 'com.testapp.web.SomeBackingBean_$$_javassist_55' does not have the property 'logout'.
> at javax.el.BeanELResolver.getBeanProperty(BeanELResolver.java:661)
> at javax.el.BeanELResolver.getValue(BeanELResolver.java:290)
> at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175)
> at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
> at com.sun.el.parser.AstValue.getValue(AstValue.java:116)
> at com.sun.el.parser.AstValue.getValue(AstValue.java:163)
> at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219)
> at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:71)
> at com.sun.faces.facelets.el.ELText$ELTextVariable.toString(ELText.java:207)
> at com.sun.faces.facelets.el.ELText$ELTextComposite.toString(ELText.java:148)
> at com.sun.faces.facelets.compiler.CommentInstruction.write(CommentInstruction.java:70)
> at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:75)
> at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:176)
> at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
> at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
> at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613)
> at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
> at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
> at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:380)
> at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
> at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)
> at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
> at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
> at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
> at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
> at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
> at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
> at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
> at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
> at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
> at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
> at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
> at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
> at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
> at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
> at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
> at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
> at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
> at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
> at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
> at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
> at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
> at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
> at java.lang.Thread.run(Thread.java:619)
> [/code]
>
>
> So, why does JSF attempt to evaluate EL expressions that are in comments?
>
> Furthermore, the backing bean DOES have a logout method. And if I uncomment the code, it works. No exceptions. The property exists.
> [Message sent by forum member 'vesuvius' (vesuvius_prime@hotmail.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=388713
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

Jason Lee

On 2/25/10 10:20 AM, webtier@javadesktop.org wrote:
> Hi,
>
> I have a page that looks roughly like the following:
>
> [code]
>
>
> > xmlns:h="http://java.sun.com/jsf/html"
> xmlns:f="http://java.sun.com/jsf/core">
>
> Main
>

>
>
>

>
>
>
> [/code]
>
> I know the page is useless but I intentionally created it like this, so as not to clutter the example.
>
> Please, pay attention to the fact that the EL expression is in a section that's commented out. So, it should not be evaluated.
>
> When I try to display the page, however, I get an exception:
>
I think that's because there's a misunderstanding of how Facelets
works. To comment something out in Facelets, you would wrap it in
. When Facelets finds the HTML comment, it assumes that you
have a comment that you want rendered to the client, which in this case,
includes parsing EL. If I recall, JSP behaved the same way (but it's
been YEARS since I've used JSP, thankfully :).

So, short answer, use instead of

>
>
>
> [/code]
>
> I know the page is useless but I intentionally created it like this, so as
> not to clutter the example.
>
> Please, pay attention to the fact that the EL expression is in a section
> that's commented out. So, it should not be evaluated.
>
> When I try to display the page, however, I get an exception:
>
> [code]
> An Error Occurred:
> The class 'com.testapp.web.SomeBackingBean_$$_javassist_55' does not have
> the property 'logout'.
>
> javax.el.PropertyNotFoundException: The class
> 'com.testapp.web.SomeBackingBean_$$_javassist_55' does not have the property
> 'logout'.
> at javax.el.BeanELResolver.getBeanProperty(BeanELResolver.java:661)
> at javax.el.BeanELResolver.getValue(BeanELResolver.java:290)
> at
> javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175)
> at
> com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
> at com.sun.el.parser.AstValue.getValue(AstValue.java:116)
> at com.sun.el.parser.AstValue.getValue(AstValue.java:163)
> at
> com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219)
> at
> org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:71)
> at
> com.sun.faces.facelets.el.ELText$ELTextVariable.toString(ELText.java:207)
> at
> com.sun.faces.facelets.el.ELText$ELTextComposite.toString(ELText.java:148)
> at
> com.sun.faces.facelets.compiler.CommentInstruction.write(CommentInstruction.java:70)
> at
> com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:75)
> at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:176)
> at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
> at
> javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
> at
> javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613)
> at
> javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
> at
> javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
> at
> com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:380)
> at
> com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
> at
> javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)
> at
> com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
> at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
> at
> com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
> at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
> at
> org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
> at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
> at
> com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
> at
> org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
> at
> com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
> at
> com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
> at
> com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
> at
> com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
> at
> com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
> at
> com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
> at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
> at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
> at
> com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
> at
> com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
> at
> com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
> at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
> at
> com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
> at
> com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
> at java.lang.Thread.run(Thread.java:619)
> [/code]
>
>
> So, why does JSF attempt to evaluate EL expressions that are in comments?
>
> Furthermore, the backing bean DOES have a logout method. And if I uncomment
> the code, it works. No exceptions. The property exists.
> [Message sent by forum member 'vesuvius' (vesuvius_prime@hotmail.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=388713
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>
[att1.html]