This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
kalle suresh
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i too got this error ...i cant't too fix it!!!
 
Wayne Wong Qi Yuan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i also got this problem... anyone can help?
 
Tim Holloway
Saloon Keeper
Posts: 18303
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
kalle suresh
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18303
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18303
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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().

 
Ramy Nady
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Tim Holloway wrote:

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.


This notes fixed my problem also

I was using the bean name UserMovieBean in my xhtml pages , when I moved it to userMovieBean it is working as expected.
"instance names, not class names,can't begin with upper-case letter"

Thanks a lot for your help
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic