Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF 2.0 - PropertyNotFoundException

 
Ast Lavond
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello together,

I want to run a very simple JSF 2 example, but it ends always in this error:
javax.el.PropertyNotFoundException: /index.xhtml @12,39 value="#{user.name}": Target Unreachable, identifier 'user' resolved to null

After searching I found a lot of links with similar problems. For example:

http://www.coderanch.com/t/505989/JSF/java/Error#2284390
http://www.coderanch.com/t/502157/JSF/java/JSF-Spring-managing-beans#2264029

But in my case it doesn't help.

I’ve created a Dynamic Web Project in Eclipse Helios based on the Target runtime “JBoss 6.0 Runtime” and with the JSF 2.0 Configuration.
The Java Build Path contains the following libraries:
- JBoss 6.0 Runtime (with all needed jars provided by jBoss)
- JRE System Library [JVM 1.6.0]


After that I've created these files:

User.java:


index.xhtml:


greet.xhtml


web.xml


I also tested the user.java class with the @ManagedBean annotation and with the corresponding faces-config.xml settings. -> with no success.
Do you have a solution?
 
Cesar Loachamin
Ranch Hand
Posts: 90
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ast
I think the problem is with your packages becuase depending of the anotation of your bean you choose the scope in the correct package, I give you an example:
orCheck your packages, I hope this help you with your problems. Regards
Cesar
 
Ast Lavond
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Cesar,

thanks for your reply. I found the Problem:

In Eclipse you can build web and enterprise archive projects by adding them to server (right click on the project -> run as -> run on server -> now you can choose the specific server instance -> the archive will be generated in your deploy folder).

So now the strange thing:
In my case the WAR archive will be generated (with all packages), but the java files in the source folder will not be considered. I’ve tried to build the archive again: Now in the server view -> I stated an incremental / full publish of the project -> without success.
But If I run an POJO with a main methode in the same Package, all other POJOs will be compiled and updated to the archive.

-> In future I will build my applications with ant ;)

Unfortunately my Applications runs only with the User.java as Managed Bean (with Annotations or defined in faces-config.xml):

...Managed Bean with Annotations:


...or Managed Bean defined in faces-config.xml:




Injection doesn’t work (javax.el.PropertyNotFoundException):



 
Cesar Loachamin
Ranch Hand
Posts: 90
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ast

I'm glad becuase you can solve the principal problem, sorry I forgot to told you about the Named annotation, when you want to use a Context and Dependency Injection with JSF 2.0, you need a configuration file beans.xml to indicate to the container that you want to use CDI. Here is the content of the beans.xml (you can leave this file in blank)
and you need put this file at the same level as web.xml withing the war

I hope with this you can use CDI in you project
Kind Regards
Cesar
 
Ast Lavond
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Cesar,

that was the mistake, now all runs great.
Thanks a lot for your help!

Best Regards
Ast
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic