1. java
  2. android
  3. c#
  4. .net
  5. javascript
  6. php
  7. jquery
  8. html
  9. sql

Erro Method not found

Pessoal, estou com uma dificuldade em um projeto. O projeto usa o padrão Maven; e EJB (Wildfly), JSF, JPA (Hibernate), PrimeFaces e OmniFaces (Conversor). Existe uma página funcionario.xhtml que é para cadastrar funcionário relacionando ele a uma empresa (@ManyToOny). A página aparece normalmente, mas na hora de salvar o funcionário gera um erro alegando que o método salvar não foi localizado. No entanto já fiz diversos testes e pesquisei na net e vi bastante assunto com esse mesmo erro, mas nada resolveu a minha questão.

Antes de colar trechos do meu código, deixo aqui o link do GitHub para ver ele completo: https://github.com/hugoan/sindiatacadista

Log erro

00:16:10,506 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (default task-10) #{funcionarioBean.salvar}: javax.el.MethodNotFoundException: /funcionario.xhtml @63,73 action="#{funcionarioBean.salvar}": Method not found: class br.com.sindiatacadista.bean.FuncionarioBean$Proxy$_$$_WeldSubclass.salvar(): javax.faces.FacesException: #{funcionarioBean.salvar}: javax.el.MethodNotFoundException: /funcionario.xhtml @63,73 action="#{funcionarioBean.salvar}": Method not found: class br.com.sindiatacadista.bean.FuncionarioBean$Proxy$_$$_WeldSubclass.salvar()
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:110)
    at javax.faces.component.UICommand.broadcast(UICommand.java:315)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
    at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
    at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
    at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
    at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
    at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
    at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
    at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
    at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: javax.faces.el.MethodNotFoundException: javax.el.MethodNotFoundException: /funcionario.xhtml @63,73 action="#{funcionarioBean.salvar}": Method not found: class br.com.sindiatacadista.bean.FuncionarioBean$Proxy$_$$_WeldSubclass.salvar()
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    ... 45 more
Caused by: javax.el.MethodNotFoundException: /funcionario.xhtml @63,73 action="#{funcionarioBean.salvar}": Method not found: class br.com.sindiatacadista.bean.FuncionarioBean$Proxy$_$$_WeldSubclass.salvar()
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:109)
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
    ... 46 more

00:16:10,514 SEVERE [javax.enterprise.resource.webcontainer.jsf.context] (default task-10) javax.faces.el.MethodNotFoundException: javax.el.MethodNotFoundException: /funcionario.xhtml @63,73 action="#{funcionarioBean.salvar}": Method not found: class br.com.sindiatacadista.bean.FuncionarioBean$Proxy$_$$_WeldSubclass.salvar()
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    at javax.faces.component.UICommand.broadcast(UICommand.java:315)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
    at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
    at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
    at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
    at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
    at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
    at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
    at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
    at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: javax.el.MethodNotFoundException: /funcionario.xhtml @63,73 action="#{funcionarioBean.salvar}": Method not found: class br.com.sindiatacadista.bean.FuncionarioBean$Proxy$_$$_WeldSubclass.salvar()
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:109)
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
    ... 46 more

Model

package br.com.sindiatacadista.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;

@SuppressWarnings("serial")
@Entity
public class Funcionario implements Serializable{

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(nullable = false, length = 150)
    private String nome;

    @Column(nullable = false, length = 14, unique = true)
    private String cpf;

    @Column(nullable = false, length = 80)
    private String email;

    @Column(nullable = false, length = 80)
    private String departamento;

    @Column(nullable = false, length = 80)
    private String funcao;

    @ManyToOne(optional = false)
    private Empresa empresa;

    @Column(nullable = false, length = 4)
    private String ativo;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getCpf() {
        return cpf;
    }

    public void setCpf(String cpf) {
        this.cpf = cpf;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getDepartamento() {
        return departamento;
    }

    public void setDepartamento(String departamento) {
        this.departamento = departamento;
    }

    public String getFuncao() {
        return funcao;
    }

    public void setFuncao(String funcao) {
        this.funcao = funcao;
    }

    public Empresa getEmpresa() {
        return empresa;
    }

    public void setEmpresa(Empresa empresa) {
        this.empresa = empresa;
    }

    public String getAtivo() {
        return ativo;
    }

    public void setAtivo(String ativo) {
        this.ativo = ativo;
    }


    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Funcionario other = (Funcionario) obj;
        if (id == null) {
            if (other.id != null)
                return false;
        } else if (!id.equals(other.id))
            return false;
        return true;
    }

    @Override
    public String toString() {
        return String.format("%s[id=%d]", getClass().getSimpleName(), getId());
    }

}

Dao

package br.com.sindiatacadista.dao;

import java.io.Serializable;
import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import br.com.sindiatacadista.model.Funcionario;

@SuppressWarnings("serial")
@Stateless
public class FuncionarioDAO implements Serializable {

    @PersistenceContext
    private EntityManager em;


    public void gravar(Funcionario funcionario) {
        this.em.persist(funcionario);
    }


    public void atualizar(Funcionario funcionario){
        this.em.merge(funcionario);
    }


    public void remover(Funcionario funcionario){
        this.em.remove(funcionario);
    }

    public List<Funcionario> listaTodosFuncionariosDaEmpresa(){
        return this.em.createQuery("select f from Funcionario f join f.empresa", Funcionario.class).getResultList();
    }
}

Bean

package br.com.sindiatacadista.bean;

import java.io.Serializable;
import java.util.List;

import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import javax.transaction.Transactional;

import br.com.sindiatacadista.dao.EmpresaDAO;
import br.com.sindiatacadista.dao.FuncionarioDAO;
import br.com.sindiatacadista.model.Empresa;
import br.com.sindiatacadista.model.Funcionario;

@Named
@ViewScoped
@SuppressWarnings("serial")
public class FuncionarioBean implements Serializable {

    private Funcionario funcionario = new Funcionario();


    @Inject
    private FuncionarioDAO funcionarioDAO;

    @Inject
    private EmpresaDAO empresaDAO;

    @Transactional
    public void salvar(Funcionario funcionario) {
        System.out.println("O método salvar da classe funcionarioBean recebeu o seguinte funcionario: " + funcionario);
        if (funcionario.getId() == null) {
            this.funcionarioDAO.gravar(funcionario);
        } else {
            this.funcionarioDAO.atualizar(funcionario);
        }
    }

    // Gets e Sets
    public Funcionario getFuncionario() {
        return funcionario;
    }

    public void setFuncionario(Funcionario funcionario) {
        this.funcionario = funcionario;
    }

    public List<Funcionario> getFuncionarios() {
        return this.funcionarioDAO.listaTodosFuncionariosDaEmpresa();
    }

    public List<Empresa> getEmpresas(){
        return this.empresaDAO.listaTodasEmpresas();
    }
}

funcionario.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<h:html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">

<h:head />
<h:body>

   <p:growl id="messages" showDetail="true" autoUpdate="true"/>

    <h:form id="formCadFuncionario">

        <p:fieldset legend="Cadastro de Funcionario">
            <h:panelGrid columns="2">

                <p:outputLabel for="nome" value="Nome" />
                <p:inputText id="nome" value="#{funcionarioBean.funcionario.nome}"
                    required="true" requiredMessage="Informe o nome" />

                <p:outputLabel for="cpf" value="CPF" />
                <p:inputMask id="cpf" value="#{funcionarioBean.funcionario.cpf}"
                    mask="999.999.999-99" required="true"
                    requiredMessage="Informe o CPF" />

                <p:outputLabel for="email" value="E-mail" />
                <p:inputText id="email" value="#{funcionarioBean.funcionario.email}"
                    required="true" requiredMessage="Informe o e-mail" />

                <p:outputLabel for="empresa" value="Empresa" />
                <p:selectOneMenu id="empresa" value="#{funcionarioBean.funcionario.empresa}" converter="omnifaces.SelectItemsConverter"
                    style="width:125px" required="true" requiredMessage="Informe o departamento">
                    <f:selectItem noSelectionOption="true" itemLabel="Selecione a empresa" />
                    <f:selectItems value="#{funcionarioBean.empresas}" var="empresa"
                        itemValue="#{empresa}" itemLabel="#{empresa.razaoSocial}" />
                </p:selectOneMenu>

                <p:outputLabel for="departamento" value="Departamento" />
                <p:selectOneMenu id="departamento" value="#{funcionarioBean.funcionario.departamento}"
                    style="width:125px" required="true"
                    requiredMessage="Informe o departamento">
                    <f:selectItem itemLabel="Selecione o departamento" itemValue="" />
                    <f:selectItem itemLabel="Administrativo" itemValue="Administrativo" />
                    <f:selectItem itemLabel="Contabil" itemValue="Contabil" />
                    <f:selectItem itemLabel="RH" itemValue="RH" />
                </p:selectOneMenu>

                <p:outputLabel for="funcao" value="Função" />
                <p:inputText id="funcao"
                    value="#{funcionarioBean.funcionario.funcao}" required="true"
                    requiredMessage="Informe a função" />

                <p:outputLabel for="cadastroAtivo" value="Cadastro Ativo" />
                <p:selectOneRadio id="cadastroAtivo"
                    value="#{funcionarioBean.funcionario.ativo}" required="true"
                    requiredMessage="Informe o estado do cadastrado">
                    <f:selectItem itemValue="Sim" itemLabel="Sim" />
                    <f:selectItem itemValue="Não" itemLabel="Não" />
                </p:selectOneRadio>

                <p:commandButton value="Salvar" action="#{funcionarioBean.salvar}"/>

            </h:panelGrid>
        </p:fieldset>
    </h:form>
</h:body>
</h:html>
  1. Você vai ver essas setas em qualquer página de pergunta. Com elas, você pode dizer se uma pergunta ou uma resposta foram relevantes ou não.
  2. Edite sua pergunta ou resposta caso queira alterar ou adicionar detalhes.
  3. Caso haja alguma dúvida sobre a pergunta, adicione um comentário. O espaço de respostas deve ser utilizado apenas para responder a pergunta.
  4. Se o autor da pergunta marcar uma resposta como solucionada, esta marca aparecerá.
  5. Clique aqui para mais detalhes sobre o funcionamento do GUJ!

1 resposta

Não é a resposta que estava procurando? Procure outras perguntas com as tags jsf ejb cdi ou faça a sua própria pergunta.