Galera, estou com o seguinte erro :javax.servlet.ServletException: /Incluir.xhtml @14,27 value="#{clienteMB.cliente.nome}": Target Unreachable, ‘cliente’ returned null
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
Mas possuo o managed bean clienteMB e tb a classe ja instanciada cliente com o get e set nome.
segue managed bean
package managedbean;
import java.util.ArrayList;
import java.util.List;
import ejb.ClienteBean;
import entidade.Cliente;
@ManagedBean (name = “clienteMB” )
@ViewScoped
public class ClienteMB {
private Cliente cliente = new Cliente();
private List<Cliente> lstCliente = new ArrayList<Cliente>();
public String incluirCliente() {
InitialContext ini;
try {
ini = new InitialContext();
ClienteBean clienteBean = (ClienteBean)ini.lookup("java:module/ClienteBean");
clienteBean.salvar(cliente);
cliente = new Cliente();
lstCliente = clienteBean.buscarClientes();
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public Cliente getCliente() {
return cliente;
}
public void setCliente(Cliente cliente) {
this.cliente = cliente;
}
public List<Cliente> getLstCliente() {
return lstCliente;
}
public void setLstCliente(List<Cliente> lstCliente) {
this.lstCliente = lstCliente;
}
}
segue xhtml
<h:head><title>Minha Aplicação</title></h:head>
<h:body>
<h:form>
<h:outputLabel value="Nome: " for="nome" />
<h:inputText id="nome" value="#{clienteMB.cliente.nome}" required="true" requiredMessage="Campo obrigatório"
maxlength="200"/>
<h:commandButton value="Salvar" action="#{clienteMB.incluirCliente()}" />
</h:form>
<h:dataTable id="tabela" value="#{clienteMB.lstCliente}" var="item">
<h:column>
<f:facet name="header">
<h:outputText value="ID" />
</f:facet>
<h:outputText value="#{item.id}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Nome" />
</f:facet>
<h:outputText value="#{item.nome}"/>
</h:column>
</h:dataTable>
</h:body>
Aguem pode me ajudar?
Obrigado