This question already has an answer here:
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>
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.
Thanks @PM77-1
You need
@ManagedBean(name="userBean")
Make sure you have
getUser()
method.Type of
setUser()
method should bevoid
.Make sure that
User
class has propersetters
andgetters
as well.I want to share my experience with this Exception. My JSF 2.2 application worked fine with WildFly 8.0, but one time, when I started server, i got this "Target Unreacheable" exception. Actually, there was no problem with JSF annotations or tags.
Only thing I had to do was cleaning the project. After this operation, my app is working fine again.
I hope this will help someone!