jsfjsf-2.2managed-bean

Target Unreachable, identifier resolved to null in JSF 2.2


I have a problem with JSF 2.2 and CDI, my managerbean is not solved and this error appear

"value="#{userBean.user.name}": Target Unreachable, identifier 'userBean' resolved to null"

This is my manager bean.

@ManagedBean
@RequestScoped
public class UserBean implements Serializable {
    private User user;

    public void setUser(user) {
        this.user = user;
    }
    ...
}

My view is:

<h:form id="login-form">
    <h:outputText value="User"/>
    <h:inputText value="#{userBean.user.name}" id="username"/>

    <h:outputText value="Senha"/>
    <h:inputSecret value="#{userBean.user.password}" id="pasword"/>

    <h:commandButton id="button" value="Login" action="#{userBean.login}"/>

    <h:messages />
</h:form>

Solution

  • I solved this problem.

    My Java version was the 1.6 and I found that was using 1.7 with CDI however after that I changed the Java version to 1.7 and import the package javax.faces.bean.ManagedBean and everything worked.

    Right click on Project > Properties > Java Compiler > Make Sure the Java version installed in class path is same as the java compiler. Thanks @PM77-1