Olá pessoal estou com o seguinte erro java.lang.NullPointerException no metodo de listar em um sistema web que estou fazendo. estou trabalhando com as camadas domain, dao, bean, e a parte jsf
ja testei o metodo no dao e no bean e funciona perfeitamente porem ao querer listar em uma tabela no jsf da erro segue o codigo caso alguem queira me ajudar grato desde ja.
DAO----------------------------------------------------------------------------------------------------------------
public ArrayList Listar() {
ConexaoBD conex = new ConexaoBD();
conex.Conexao();
conex.executaSql(“select * from fabricante order by nome”);
ArrayList lista = new ArrayList();
try {
conex.rs.first();
do {
Fabricante fabricante = new Fabricante();
fabricante.setCodigo(conex.rs.getInt(“codigo”));
fabricante.setNome(conex.rs.getString(“nome”));
fabricante.setCnpj(conex.rs.getString(“cnpj”));
fabricante.setTelefone(conex.rs.getString(“telefone”));
fabricante.setResponsavel(conex.rs.getString(“responsavel”));
lista.add(fabricante);
} while (conex.rs.next());
} catch (SQLException ex) {
System.out.println("Erro em realizar pesquisa do fabricante" + ex);
JSFUtil.mensagemErro("Erro em realizar pesquisa do fabricante" + ex);
}
conex.Desconecta();
return lista;
}
BEAN--------------------------------------------------------------------------------------------
@ManagedBean(name = “MBFabricante”)
@ViewScoped
public class FabricanteBean {
private ArrayList ListaFabricantes;
public ArrayList getListaFabricantes() {
return ListaFabricantes;
}
public void setListaFabricantes(ArrayList<Fabricante> ListaFabricantes) {
this.ListaFabricantes = ListaFabricantes;
}
public void listar() {
FabricanteDao dao = new FabricanteDao();
ListaFabricantes = dao.Listar();
}
JSF----------------------------------------------------------------------------------------------------------------
<?xml version='1.0' encoding='UTF-8' ?><ui:composition xmlns="<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>"
xmlns:ui="<a href="http://java.sun.com/jsf/facelets">http://java.sun.com/jsf/facelets</a>"
template="templates/modeloGeral.xhtml"
xmlns:p=“<a href="http://primefaces.org/ui">http://primefaces.org/ui</a>"
xmlns:f=“<a href="http://java.sun.com/jsf/core">http://java.sun.com/jsf/core</a>"
xmlns:h=“<a href="http://xmlns.jcp.org/jsf/html">http://xmlns.jcp.org/jsf/html</a>”>
<ui:define name=“metadata”>
<f:metadata>
<f:event listener=”#{MBFabricante.listar()}” type=“preRenderView”/>
</f:metadata>
</ui:define>
<ui:define name="menu">
<ui:include src="includes/menuPrincipal.xhtml"/>
</ui:define>
<ui:define name="conteudo">
<h:form id="frmTabela">
<p:dataTable id="tabela" widgetVar="table" value="#{MBFabricante.listaFabricantes}" var="item" paginator="true" rows="11" emptyMessage="Nenhum registro encontrado">
<f:facet name="header">
<h:outputText value="Listagem de fabricantes"/>
</f:facet>
<p:column headerText="Codigo">
<h:outputText value="#{item.codigo}"/>
</p:column>
<p:column headerText="Nome">
<h:outputText value="#{item.nome}"/>
</p:column>
<p:column headerText="Cnpj">
<h:outputText value="#{item.cnpj}"/>
</p:column>
<p:column headerText="Telefone">
<h:outputText value="#{item.telefone}"/>
</p:column>
<p:column headerText="Responsavel">
<h:outputText value="#{item.responsavel}"/>
</p:column>
<p:column headerText="Opções">
<p:commandButton icon="ui-icon-trash" oncomplete="PF('dlgExcluir').show();" update=":formexcluir:pnlExcluir">
</p:commandButton>
<p:commandButton icon="ui-icon-pencil" oncomplete="PF('dlgAlterar').show();" update=":frmAlterar:panelAlterar">
</p:commandButton>
</p:column>
</p:dataTable>
</h:form>