I’m trying to get a simple JSF 2 tutorial example to work.
I am using the dynamic web project in Eclipse and am publishing to a Glassfish 3 server (run -> run on server). The first index.xhtml page loads successfully, but when I need to access a managed bean, I get the following error:
/index.xhtml @14,48 value="#{helloBean.name}": Target Unreachable, identifier 'helloBean' resolved to null
I have looked at the various other discussions on this topic, however the solutions seem not to work for me (e.g. adding beans.xml, giving the managed bean a name etc., following the naming conventions).
Any help would be appreciated.
Here is the code I’m currently working with:
Index.xhtml
JSF 2.0 Hello World
JSF 2.0 Hello World Example - hello.xhtml
response.xhtml:
JSF 2.0 Hello World
JSF 2.0 Hello World Example - welcome.xhtml
Welcome #{helloBean.name}
Bean managed:
package Java.hello1;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import Java.io.Serializable;
@ManagedBean
@SessionScoped
public class HelloBean implements Serializable {
private static final long serialVersionUID = 1L;
private String name = "Ricardo";
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
web.xml:
JavaServerFaces
javax.faces.PROJECT_STAGE
Development
faces/index.xhtml
Faces Servlet
javax.faces.webapp.FacesServlet
1
Faces Servlet
/faces/*
Faces Servlet
*.jsf
Faces Servlet
*.faces
Faces Servlet
*.xhtml