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: /index.xhtml @17,44 value= 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: /index.xhtml @17,44 value="#{user.Name}": Target Unreachable, id" Watch "javax.el.PropertyNotFoundException: /index.xhtml @17,44 value="#{user.Name}": Target Unreachable, id" New topic
Author

javax.el.PropertyNotFoundException: /index.xhtml @17,44 value="#{user.Name}": Target Unreachable, id

kalle suresh
Ranch Hand

Joined: Nov 20, 2007
Posts: 48
Hi,

I am running sample JSF with a

1. login page asking for the user name and password.
2. after entering the user name and password, greet the user with Hello User Name..

Here are the configuration details.
1. Eclipse Helios
2. Tomcat 6
3. JSF Version 2


The following are the list of files.

1. index.xhtml - containing the input boxes for user name and password.
2. User.java - Bean having the properties for user name and password. once after entering the user name and password at index.xhtml values need to be stored here.
3. welcome.xhtml - This will retrieve the user name from user.java and put a message..


I have attached my files here.

1.index.html


2. User.java


3. welcome.xhtml



4.web.xml


5.faces-config.xml


Here are the list of libraries I am using..
javax.faces.jar
jstl-1.2.jar

I am able to see the login page and after input the user name and password and click on login button I could see the following error.






Please help me in resolving this..

Thanks,
Suresh.
ban Parth
Greenhorn

Joined: May 23, 2012
Posts: 2
i too got this error ...i cant't too fix it!!!
Wayne Wong Qi Yuan
Greenhorn

Joined: May 30, 2012
Posts: 4
i also got this problem... anyone can help?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15950
    
  19

You defined the bean with a name of "User" but you're referencing it under a name of "user". Java is case-sensitive, so the name does not resolve.

Some additional notes:

1. JSF object names are instance names, not class names, so they should not begin with an upper-case letter.

2. Writing your own login code is suicide. J2EE has a truly secure login mechanism and it doesn't require user-written code.


Customer surveys are for companies who didn't pay proper attention to begin with.
kalle suresh
Ranch Hand

Joined: Nov 20, 2007
Posts: 48
Hi,

I tried changing the User to user and the properties which I am referring in xhtml as the way they are declared in bean class. But no luck.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15950
    
  19

kalle suresh wrote:Hi,

I tried changing the User to user and the properties which I am referring in xhtml as the way they are declared in bean class. But no luck.


I recommend that you study up on basic Javabeans and POJOs. And maybe fundamental Java conventions.

Most of your problems are not related to JSF or web programming, but are due to failure to observe these conventions. Java class names begin with an uppercase letter. instance names do not and that includes property names. So it's not "#{User.Name}" or "#{user.Name}", it's "#{user.name}" and the get/set methods on the backing bean are named "getName()" and "setName()".
long shan
Greenhorn

Joined: Jun 27, 2012
Posts: 1
kalle suresh wrote:Hi,

I am running sample JSF with a

1. login page asking for the user name and password.
2. after entering the user name and password, greet the user with Hello User Name..

Here are the configuration details.
1. Eclipse Helios
2. Tomcat 6
3. JSF Version 2


The following are the list of files.

1. index.xhtml - containing the input boxes for user name and password.
2. User.java - Bean having the properties for user name and password. once after entering the user name and password at index.xhtml values need to be stored here.
3. welcome.xhtml - This will retrieve the user name from user.java and put a message..


I have attached my files here.

1.index.html


2. User.java


3. welcome.xhtml



4.web.xml


5.faces-config.xml


Here are the list of libraries I am using..
javax.faces.jar
jstl-1.2.jar

I am able to see the login page and after input the user name and password and click on login button I could see the following error.






Please help me in resolving this..

Thanks,
Suresh.





i think you havn't study JSF good,y or n?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15950
    
  19

OK, I could make my usual comment about how user-written login processing means that the webapp comes pre-supplied with security problems from the start, but the particular problem you are having stems from you not understanding how JavaBeans work.

The convention for JavaBeans - and Java in general - is that classnames start with an uppercase letter and class instance and member names start with a lower-case letter. So the bean should be named "user", not "User". On the @ManagedBean annotation, simply removing the "name=" parameter will accomplish that, since the default name generated is the class name with its initial letter folded to lower-case. At the moment, you are failing to find the "user" object because the EL resolver is case-sensitive and cannot find an object named "User" using the id of "user".

That's problem #1. Problem #2 is similar. As I said, member (property) names also must start with a lower-case letter, so instead of "#{user.Name}", it has to be "#{user.name}". The property accessor methods in the User class will then be getName() and setName().

 
Consider Paul's rocket mass heater.
 
subject: javax.el.PropertyNotFoundException: /index.xhtml @17,44 value="#{user.Name}": Target Unreachable, id
 
Similar Threads
Unable to create managed bean. Hello world app.
ICEfaces configured for view /*.xhtml but h:head and h:body components not seen
Primefaces setup causing problems JSF 2.0
Don't work any jfs scripts
Error