File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes javax.el.PropertyNotFoundException: Property 'logoutUser' not found on type org.ssc.webapp.UserLogin Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "javax.el.PropertyNotFoundException: Property Watch "javax.el.PropertyNotFoundException: Property New topic
Author

javax.el.PropertyNotFoundException: Property 'logoutUser' not found on type org.ssc.webapp.UserLogin

Steve Hespelt
Greenhorn

Joined: Jan 11, 2011
Posts: 6
I'm a JSF/RichFaces/Facelets greenhorn but I'm trying to change that.
I'm implementing my first RichFaces (JDK 1.6.0_22, RichFaces 3.3.3-Final, JSF 2.0 - using mojarra-2.0.3-FCS, Tomcat 6.0.26 )

my faces-config.xml has a managed bean 'userLogin' whose class has a public non-static method named 'logoutUser' - returns a String object, has no arguments.
within my facelets xhtml template page, I have a h:commandButton within an h:form element.
This h:commandButton element uses the following action attribute: action="#{userLogin.logoutUser}"

I'm confused as to why this exception is occurring as it is my current understanding that the action value should be interpreted as an action method, not as a property value binding as the bean's impl class has no bean get/set 'property' methods by that name.

using javap to verify the presence of the method confirms it:
public java.lang.String logoutUser();
(I pass my webapp's classpath to javap to mimic )
The -verbose:class JVM argument when running Tomcat shows the bean's impl class being loaded well before the javax.el.PropertyNotFoundException is thrown.

Am I missing some key aspect that will result in the action attribute being uses as an action method versus a property value binding expression ?

MTIA for any insights/suggestions,
-Steve
Cesar Loachamin
Ranch Hand

Joined: Dec 25, 2010
Posts: 90

Hi Steve

When you use a action attribute you bind a method expression, A method expression in an action attribute has no parameters. It can have any return type. The return value is converted to a string by calling toString, the method returns an outcome string which is used to determine the next view. Since JSF 2.0 you can pass parameters to the method, but if you use a servlet container as Tomcat you must include the jar of the EL 2.2 in the lib folder of your application and configure the <param-name>com.sun.faces.expressionFactory</param-name> in the web.xml.

I'm not sure what exactly is your problem, but when the jsf implementation not found the method specified in the action attribute this launches a javax.el.MethodNotFoundException.

Regards

Cesar


When a dream is ending because to come true - OCPJP 6,7. OCE JPA EE6. MCTS
Steve Hespelt
Greenhorn

Joined: Jan 11, 2011
Posts: 6
Hi Cesar,
thanks for replying.
Tomcat throws the exception when loading the Facelet page containing the commandButton with the action attribute set to the #{userLogin.logoutUser} method.
Tomcat 6.0.26 comes with el-2.1.jar.
I'll get the 2.2 jar and add the <param-name>com.sun.faces.expressionFactory</param-name> to my app's web.xml

I see that glassfish 3.1-b29 comes with el-impl.jar which is version 2.2.1.b03.

This page http://stackoverflow.com/questions/2333605/using-el-2-2-with-tomcat-6-0-24/3808138#3808138
has the same info as your answer:
As mentioned in other answers, you need to add the el-api-2.2.jar to your Tomcat server's lib folder, and the el-impl-2.2.jar to your WEB-INF/lib folder.

Other answers mention deleting jasper or creating custom implementations of ExpressionFactoryImpl. That might work, but you shouldn't need to do that.

You just need to override the expression factory implementation using org.apache.myfaces.EXPRESSION_FACTORY on MyFaces or com.sun.faces.expressionFactory on Mojarra.

<context-param>
<param-name>org.apache.myfaces.EXPRESSION_FACTORY</param-name>
<param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>



I'll update the el jars and post an update with my results.
Thanks again for your help,
-Steve
Steve Hespelt
Greenhorn

Joined: Jan 11, 2011
Posts: 6
Update & exception stack trace
I replaced the el-impl.jar, el-api.jar's, added the com.sun.faces.expressionFactory context param & still get the same exception.
As you can see from the stack trace, the facelets code is trying to treat this as a property rather than the intended action method. I have no idea why...
-Steve

javax.el.PropertyNotFoundException: The class 'org.ssc.webapp.UserLogin' does not have the property 'logoutUser'.
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:71)
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 com.sun.facelets.el.ELText$ELTextVariable.toString(ELText.java:174)
at com.sun.facelets.el.ELText$ELTextComposite.toString(ELText.java:115)
at com.sun.facelets.compiler.CommentInstruction.write(CommentInstruction.java:38)
at com.sun.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:39)
at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:275)
at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:200)
at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:195)
at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1643)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:594)
at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:117)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
[... remaining stack trace deleted ...]
Cesar Loachamin
Ranch Hand

Joined: Dec 25, 2010
Posts: 90

Hi Steve.

It is not really necessary to configure the el 2.2, it's only necessary when you want to pass parameters to a method and you use Tomcat v6.
I have tried to reply you problem but I replicated your stage in tomcat but I have not had any problems , Can you post your Facelets page and your managed bean and your config files, to reply your stage and try to find your problem.

Regards

Cesar
Steve Hespelt
Greenhorn

Joined: Jan 11, 2011
Posts: 6
Hi Cesar,
I've attached 3 files - web.xml, my facelets template file default.xhtml & a text file containing the name of each jar in my tomcat's lib directory and the jars in my web-app's WEB-INFO/lib directory along with version info scraped from the jar's MANIFEST.MF [some of api version info, other implementation version while some have neither :-( ]

Thanks again for your help with this issue.

What is interesting is that the RichFaces 3.3.3 demo app is working just fine - installed under my /opt/apache-tomcat-6.0.26/webapps directory - The demo war file doesn't contain an el-impl.jar. I suspect one of the jboss jars has the working EL classes.

5 files are on my sites.google site [since I can't attach non-image files]
my webapp's web.xml
facelets template page with troublesome h:commandButton
file containing list of jars from Tomcat lib & my webapp's WEB-INF/lib along with MANIFEST.MF version info
my userLogin managed bean impl class
the faces-config.xml - showing userLogin as managed session bean

If there are any issues with the 3 URLs please let me know so I can correct the issue. I tested the links from the preview mode, but there may still be an issue?
Again, many thanks,
-Steve
Cesar Loachamin
Ranch Hand

Joined: Dec 25, 2010
Posts: 90

Hi Steve

Thanks for post the files I asked you, I can replicate your scenario, you have reason is a strange problem. I'll try to correct the problem, I'll post any news

Regards

Cesar



[Thumbnail for issueMethodExpression.png]

Cesar Loachamin
Ranch Hand

Joined: Dec 25, 2010
Posts: 90

Hi Steve

I found and solve your problem, the true is very easy but is confusing, I'll try to explain you, sorry by my english is not good.

The problem is with the comments and Facelets, when you are using Facelets and comments a section of your pages in reality that section is not omitted when the page is processed by the ViewHandler (Facelets), and for that reason you have a problem whith this code:When the seccion between the comments is processed the view handler process the action="#{userLogin.logoutUser}" and because the section between a comments will be treated as if it were a plain text page (paragraph),such as whether to have this: (You can this beacuase you are using facelets)

And because the jsf implementation tried to find the property logoutUser of the userLogin bean.
You can solve this deleting the section between the comments, or you can use the <ui:remove> this tag is used for the Facelet view handle skip the text between that tags.


I hope I have solved your problem, any questions I will answer.

Regards

Cesar



[Thumbnail for resolved.png]

Steve Hespelt
Greenhorn

Joined: Jan 11, 2011
Posts: 6
Hi Cesar,
That is fantastic research on your part! Silly me, I thought using the

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

took care of having the view handler skip over the comments.
I had not yet looked into the ui:remove tag - I thought (hadn't really done a deep thought analysis) that as xhtml is xml, the standard
<!-- --> stuff would suffice.

I'm going to confirm on my end that using the ui:remove tag is the solution.

FYI - I had changed the earlier usage of userLogin bean to a misnamed bean user_wrong to see how the view handler would react (if it was a rendering-time issue versus the action invocation time issue).

I'll add another post with my findings after using ui:remove.
Again, many thanks for the time & efforts on this. I suspect neither of us will forget this issue ;-)

-Steve
Cesar Loachamin
Ranch Hand

Joined: Dec 25, 2010
Posts: 90

Hi Steve

You're welcome, Yes your comment is interesting because you'right the <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name> does not allow comments to be taken into account by the view handler, but I think because you're using another view handler and desabling the default <param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name> the other view handler not load the param avax.faces.FACELETS_SKIP_COMMENTS.
You're welcome buddy, Yor're right I don't forget this issue.
Please post the result using <ui:remove>

Regards

Cesar
Steve Hespelt
Greenhorn

Joined: Jan 11, 2011
Posts: 6
Hi Cesar,

Yes!! - simply replacing the xml comment markers <!-- --> with the <ui:remove> ... </ui:remove> tags, the issue is resolved - just as you had reported.

I need to read the Facelets specification - it was my assumption that the context-param: javax.faces.FACELETS_SKIP_COMMENTS is defined in the specification but based on the observed behavior & your explanation that matches the observations, it appears to be a Sun RI construct. I wish I knew (haven't run across the documentation detailing it) the exact purpose of the javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER parameter - I see examples of the web.xml content needed to run RichFaces but very few details as to why...

I need to do more research.

Thanks again,
-Steve
Nigel Rowe
Greenhorn

Joined: Jun 17, 2012
Posts: 6
Cesar Loachamin wrote:Hi Steve

I found and solve your problem, the true is very easy but is confusing, I'll try to explain you, sorry by my english is not good.

The problem is with the comments and Facelets, when you are using Facelets and comments a section of your pages in reality that section is not omitted when the page is processed by the ViewHandler (Facelets), and for that reason you have a problem whith this code:When the seccion between the comments is processed the view handler process the action="#{userLogin.logoutUser}" and because the section between a comments will be treated as if it were a plain text page (paragraph),such as whether to have this: (You can this beacuase you are using facelets)

And because the jsf implementation tried to find the property logoutUser of the userLogin bean.
You can solve this deleting the section between the comments, or you can use the <ui:remove> this tag is used for the Facelet view handle skip the text between that tags.


I hope I have solved your problem, any questions I will answer.

Regards

Cesar


Wow! Just had the same problem and fixed it in 5 seconds. I'd been fiddling about with it for hours, and I would never have figured it out.
Thanks a million Cesar....
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15950
    
  19

Welcome to the JavaRanch, Nigel!

I don't guarantee that Cesar got your message, though. The last post in this thread was over a year and a half old. We call the process of awakening long-dead threads "waking a zombie".


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javax.el.PropertyNotFoundException: Property 'logoutUser' not found on type org.ssc.webapp.UserLogin
 
Similar Threads
commandButton/commandLink not working inside datatable
JavaScript form submit fails in IE7, works in FF and Safari
Opening Multiple Windows from a Single JSF CommandButton click
Hyperlinked datatable
Calling a backingBean method from javascript