javax.el.Methodnotfoundexception

Asked

Viewed 162 times

2

Good afternoon guys, I’d like your help for a mistake that I still don’t understand why it happens.

The situation is: I have a method in my managedBean listTurmas that loads a list so that later I can use, already tested this method in a test on the console and worked perfectly, but when calling this method via JSF is returned the following error:

javax.el.MethodNotFoundException: /paginaListagem.xhtml @13,90 action="#{controllerTurma.listarTurmas}": Method not found: [email protected]()

call JSF:

<h:form><h:commandButton value="Consultar" action="#{controllerTurma.listarTurmas}" /></h:form>

Method List DAO:

    @SuppressWarnings("unchecked")
public List<T> consultarTodos(Class<T> classe){
    EntityManager em = getEM();
    List<T> objetosBuscados = null;             
    try {           
        objetosBuscados = em.createQuery("FROM "+classe.getName()).getResultList();         
    } catch (Exception e) {
        e.printStackTrace();
    }finally {
        em.close();
    }
    return objetosBuscados;
}

Method call in Controller:

public void listarTurmas(){
TurmaNegocio tn = new TurmaNegocio();
this.turmas = tn.consultarTodos();  

for (Turma turma : turmas) {
    System.out.println(turma.getDescricao());
}}
  • How is your Mbean controllerTurma annotated? Which JSF version are you using? Using CDI?

  • So Giuliana, I use JSF 2.2, about CDI sorry but I don’t even know what rsrs are yet and Mbean has the following Annotation: @.Requestscoped @. Managedbean

  • @user54273 How’s your import from ManagedBean ?

  • It has already happened to me once, try putting () at the end of the call to the method, leaving thus: action="#{controllerTurma.listarTurmas()}", JSF understands that listarTurmas is a property and not a method without ().

  • So @Geferson already tried this option too and it hasn’t changed at all, I’ve been looking around and told to put the call in actionListner and then the error changed from "javax.el.Methodnotfoundexception" to "Method not found"

  • @Diegoaugusto, as well as import?

  • @user54273 import ..... Managedbean

  • In your case the correct is to use the "action" and not "actionListener". even so the error happens?

  • Post the full controllerTurma bean class to analyze.

  • Ah, I think I know what it is! Change your listTurmas method to return a String. In the end you give a null Return, just to test.

  • Guys, I managed to solve the damn error, I had a duplicate library in my build path, after removing it mysteriously the method worked, well, I don’t know if this really has anything to do with my mistake, but, it was the solution! obliged to all of you of heart <3!

  • @user54273 glad you were able to solve the problem, you can answer your question yourself and mark it as correct. That way you will help other people who face problems similar to yours.

  • 2

    I am voting to close this question as out of scope because the AP said the problem is solved, but did not post an answer.

Show 8 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.