Win a copy of Android Programming: The Big Nerd Ranch Guide this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

javax.el.PropertyNotFoundException: /index.xhtml @30,79 action="#{Link.Lname}": Target Unreachable,  RSS feed

 
Victor Ade
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why am i getting this error:

javax.el.PropertyNotFoundException: /index.xhtml @30,79 action="#{Link.Lname}": Target Unreachable, identifier 'Link' resolved to null


here is my jsf page


here my Link bean


here is a database class to feed link bean




this is how i connect the database when tomcat starts



And finally this is my web.xml file



what is cause of this error?
 
Tim Holloway
Bartender
Posts: 18608
68
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is all I really needed to know:

javax.el.PropertyNotFoundException: /index.xhtml @30,79 action="#{Link.Lname}": Target Unreachable, identifier 'Link' resolved to null


It tells me that you don't know JavaBeans. JavaBeans are a very important part of the Java universe, and are employed by many Java products, not just JSF, so it's essential that you should learn their rules.

I recommend that you find some good learning resources, but here are some starting points.

JavaBeans are very much sensitive to capitalization. The best-practice rule for JavaBeans, and in fact for Java in general is that class names should start with an uppercase letter. Instance names, property names and other second-class names must not.

So right off, you've committed a double offence. Your bean instance name is "Link", with a capital L and its Lname property name does too.

While JSF can allow a bean instance name to start with an uppercase letter (even though it is discouraged), you didn't put a @Named attribute on your class, and therefore the default name rule applies, which is to name the bean instance the same name as the class [b]except that the first letter is folded down to lower-case[/i]. So your View Template requested a bean named "Link", but JSF would have defined it with a name of "link". When it went to resolve, it would find nothing and silently return a null pointer.

Were that not so, JSF might have figured out that the way to reference the "Lname" property on the Link bean was via the getLname and setLname methods, although that could vary. Nevertheless, since the bean pointer itself is null, attempting to reference ANY property of the Link bean would result in the resolver's throwing a PropertyNotFound exception, because there's no bean to examine.

I could go into detail about the fact that your database code is both poor for performance and reliability reasons, but you need to study up on JavaBeans first. Until you get that right, nothing else matters.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!