Method not found using JPA

Asked

Viewed 100 times

3

I created a method for autocomplete. However when I invoke this method it is not found, follow below error:

    Advertência: /pessoal/cadastrar.xhtml @35,186 completeMethod="#{pessoalController.lookupFornecedores}": Method not found: br.com.constran.controller.PessoalController@278cae13.lookupFornecedores(java.lang.String)
    javax.el.MethodNotFoundException: /pessoal/cadastrar.xhtml @35,186 completeMethod="#{pessoalController.lookupFornecedores}": Method not found: br.com.constran.controller.PessoalController@278cae13.lookupFornecedores(java.lang.String)
        at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:109)
        at org.primefaces.component.autocomplete.AutoComplete.broadcast(AutoComplete.java:359)
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:795)
        at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:936)
        at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)

Follow method in my DAO:

Interface:

List lookupFornecedores();

Implementation of the DAO:

@Override
public List<Fornecedores> lookupFornecedores() {

    Query query = em.createQuery("SELECT f.razao FROM br.com.constran.modelo.Fornecedores f WHERE f.razao LIKE :fornecedor ");

    List<Fornecedores> fornecedores = query.getResultList();

    return fornecedores;
}
}

Follows Service layer:

Interface: List lookupFornecedores();

Implementation of the interface:

@Autowired
private PessoalDAO pessoalDAO;

@Override
public List<Fornecedores> lookupFornecedores() {
    List<Fornecedores> fornecedores = pessoalDAO.lookupFornecedores();
    return fornecedores;
}

Follow my method in my controller:

private Pessoal pessoal;
private List<Pessoal> pessoals;

@Autowired
private PessoalService pessoalService;

public String lookupFornecedores(){

   fornecedores = pessoalService.lookupFornecedores();

    return "";

}

Does anyone have any idea why the method is not being found?

1 answer

2

The Primefaces Autocomplete requires a String parameter.

In your case it should be something like: lookupFornecedores(String valorDigitado){}

  • I honestly just looked at the mistake. I can’t hit my eye and find problems.

Browser other questions tagged

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