I am trying to implement a sign up page on Tomcat server, but the backing bean isn't created, when I click the submit button I get the following error.
Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'registerBean' resolved to null at org.apache.el.parser.AstValue.getTarget(AstValue.java:98) at org.apache.el.parser.AstValue.getType(AstValue.java:82) at org.apache.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:172) at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:98)
here is the RegisterBean.java
package com.please.beans;
import java.io.Serializable;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
@Named
@SessionScoped
public class RegisterBean implements Serializable{
private String emailAddress="3234234";
private String userName;
private String password;
public String getEmailAddress() {
return emailAddress;
}
public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public void doLogin(){
System.out.println("Test sucessful");
}
}
Here is signup.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
Hello from Facelets
<h:form>
<h:outputText value="E-mail address" ></h:outputText>
<h:inputText id="emailaddress" value="#{registerBean.emailAddress}" required="true"></h:inputText>
<h:outputText value="Password"></h:outputText>
<h:inputSecret id="password" value="#{registerBean.password}"></h:inputSecret>
<h:outputText value="#{registerBean.emailAddress}"></h:outputText>
<h:commandButton action="#{registerBean.doLogin()}"></h:commandButton>
</h:form>
</h:body>
</html>
Change annotation like :
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean(name="registerBean")
@SessionScoped
public class RegisterBean implements Serializable{
//Your code here
..........................
}