What have I done to be rewarded with a
I'm getting a org.apache.jasper.el.JspMethodNotFoundException
on one of my view pages .Here's what in the jsp :
<h:panelGrid width="375px" bgcolor="#ff8040" columns="2" border="0">
<f:facet name="header">
<h:outputText value="User Login" />
</f:facet>
<h:outputLabel for="userName" rendered="true">
<h:outputText value="#{bundle.user_name_label}" />
</h:outputLabel>
<h:inputText rendered="true" value="#{user.userName}"
id="userName"></h:inputText>
<h:outputLabel for="password" rendered="true">
<h:outputText value="#{bundle.user_password_label}" />
</h:outputLabel>
<h:inputSecret id="password" value="#{user.password}"
rendered="true"></h:inputSecret>
<h:outputText value="Existing User?" style="left: auto" />
<h:commandButton id="submit" action="#{user.login}"
value="#{bundle.login_button_label}" rendered="true" />
<h:outputText value="New User?" style="left: auto" />
<h:commandLink value=" Register Here" action="newuser" />
</h:panelGrid>
and then the managed bean :
@Entity
@Table(name ="USERS")
@NamedQuery(name="UserBean.findUnique",query="SELECT u FROM UserBean u WHERE u.userName=:userName AND u.password=:password ")
publicclass UserBean{
privatestatic Logger log = Logger.getLogger(UserBean.class.getName());
privatestatic List<UserBean> users =new ArrayList<UserBean>();
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name ="ID")
privateint id;
@Column(name ="USERNAME")
private String userName;
@Column(name ="PASSWORD")
private String password;
@Transient
private String verify;
public UserBean(){
}
public String getPassword(){
return password;
}
publicvoid setPassword(String password){
this.password = password;
}
public String getUserName(){
return userName;
}
publicvoid setUserName(String userName){
this.userName = userName;
}
public String getVerify(){
return verify;
}
publicvoid setVerify(String verify){
this.verify = verify;
}
public UserBean(String username, String password){
this.userName = username;
this.password = password;
}
@SuppressWarnings("unchecked")
public String login(){
users =getEntityManager().createNamedQuery("UserBean.findUnique").setParameter("userName", getUserName()).setParameter("password", getPassword()).getResultList();
if (users.size() == 0){
FacesContext facesContext = FacesContext.getCurrentInstance();
FacesMessage facesMessage =new FacesMessage("You have entered an invalid user name and/or password");
facesContext.addMessage("loginForm", facesMessage);
return"failure";
}else{
return"success";
}
}
public EntityManager getEntityManager()throws PersistenceException{
EntityManager entityManager = getEntityManagerFactory().createEntityManager();
try{
if (entityManager ==null){
log.fine("Opening new EntityManager for this bean ...");
entityManager = getEntityManagerFactory().createEntityManager();
}
}catch (PersistenceException ex){
thrownew PersistenceException(ex);
}
return entityManager;
}
public EntityManagerFactory getEntityManagerFactory(){
return Persistence.createEntityManagerFactory("shoppingcart");
}
}
The the stack trace says :
SEVERE: Servlet.service()for servlet Faces Servlet threw exception
org.apache.jasper.el.JspMethodNotFoundException: /userLogin.jsp(55,6)'#{user.login}' Method not found: com.introspect.shoppingcart.UserBean@3f5a0.login()
at org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:71)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
at javax.faces.component.UICommand.broadcast(UICommand.java:383)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:447)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:11
And yet I do have the login()
method in my class and its public.Whats going on?

