0

Even if there is the method, I am getting method not found exception as servlet exception

My Bean's init and the method:

public void init() {
    HttpServletRequest req =
            (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
    usrLinks = db.usrLinks(String.valueOf(req.getParameter("username")));
}


public List<UserLinks> getUsrLinks() {
    return usrLinks;
}

The xhtml tags that I get the error message from:

<h:commandLink action="#{userBean.usrLinks}" value="My Links" rendered="#{loginBean.loggedin}" /> 

the exception error:

javax.servlet.ServletException: javax.el.MethodNotFoundException: /WEB-INF/template.xhtml @22,100 action="#{userBean.usrLinks}": Method not found: class bean.UserBean.usrLinks()

BlackPearl
  • 1,662
  • 1
  • 8
  • 16
  • I solved the problem using this link's third answer: https://stackoverflow.com/questions/41320279/javax-el-methodnotfoundexception-method-not-found-jsf –  Mar 30 '19 at 19:07

1 Answers1

0

From the exception, there are two solutions:

Rename getUsrLinks() to usrLinks()

or change #{userBean.usrLinks} to #{userBean.getUsrLinks}

Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249