Erro org.apache.jasper.JasperException: An exception occurred processing [/listardespesas.jsp] at line [43]

Ao executar o metodo Listar da aplicação o erro foi apresentado

Códigos:

CLASSE DAO:

    public List<Lancamento> listar() {
           
          String sql = "SELECT * FROM lancamento";
       
       try {
           PreparedStatement stmt = this.conn.prepareStatement(sql);
           ResultSet rs = stmt.executeQuery();
           List<Lancamento> listaLancamento = new ArrayList<> ();
           
           while (rs.next()) {
               Lancamento l = new Lancamento ();
          
               l.setIdLancamento (rs.getInt("idLancamento"));
               l.setDescricao(rs.getString("descricao"));
               l.setValor(rs.getString("valor"));
               l.setData(rs.getDate("data_hora"));
               l.setTipo(rs.getString("tipo"));
               
          listaLancamento.add(l);

           }
      return listaLancamento;
      
       } catch (Exception ex) {
            System.out.println ( "Erro ao buscar" + ex);
       }
         return null;
    }

    }

Página jsp

<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="dao.LancamentoDAO"%>
<%@page import="entidade.Lancamento"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
   <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
        <!-- Linha para utilizar o bootstrap -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
        <!-- Linha para utilizar o JavaScript -->
       <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
       <%@include file="menu.jsp" %> 
        </head>
    <body>
        <table class="table table-striped">
  <thead>
    <tr>
      <th scope="col">ID</th>
      <th scope="col">Descrição</th>
      <th scope="col">Valor</th>
      <th scope="col">Data</th>
      <th scope="col">Tipo</th>   
      <th scope="col"></th>
      <th scope="col"></th>
    </tr>
    <%
        
        String idlan = "";
        String ds = "";
        String va = "";
        String datadespesa = "";
        String ti = "";
      //String ac = (String) request.getAttribute("relatorio");
      
            LancamentoDAO lanDAO = new LancamentoDAO ();
            Lancamento lan = new Lancamento ();
            
            List<Lancamento> listaLancamento = lanDAO.listar();
            for (int i = 0; i < listaLancamento.size(); i++) {                
                lan = listaLancamento.get(i);
            
              idlan = String.valueOf(lan.getIdLancamento());
              ds =  String.valueOf (lan.getDescricao());
              va = String.valueOf(lan.getValor());
              datadespesa = String.valueOf(lan.getData());
              ti = String.valueOf(lan.getTipo());
 
               %>

       <tr>
              <th scope="row"><%=idlan%></th>
              <td><%=ds%></td>
              <td><%=va%></td>
              <td><%=datadespesa%></td>
              <td><%=ti%></td>
             
              <td><a href="busca.do?codigo=<%=idlan%>" >Alterar</a></td>
              <td>
                 <a href="del?codigo=<%=idlan%>" onclick="return confirm('Confirma exclusão do registro <%=ds%>?')">Ecluir </a>   
                 
              </td>
            </tr>
          
            <%  } 
        %>
         
        </table>
</html>

SERVLET

package servlet;

import dao.LancamentoDAO;
import entidade.Lancamento;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ServletBuscar extends HttpServlet {

    /**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
     * methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        try (PrintWriter out = response.getWriter()) {
            
            int idLan = Integer.valueOf(request.getParameter("idLancamento"));
            out.print("Codigo que chegou " + idLan);
            Lancamento lan = new Lancamento ();//criando o objeto do tipo entidade para setar o valores de retorno
            LancamentoDAO landao = new LancamentoDAO ();//criando o objeto do tipo dao para executar o metodo pesquisar
            lan = (Lancamento) landao.listar();
   
            request.setAttribute("idLancamento", lan.getIdLancamento());
            request.setAttribute("descricao", lan.getDescricao());
            request.setAttribute("valor", lan.getValor());
            request.setAttribute("data", lan.getData());
            request.setAttribute("tipo", lan.getTipo());

            RequestDispatcher rd = request.getRequestDispatcher("alterarFinanceiro.jsp");
            rd.forward(request, response);
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
          try {
            processRequest(request, response);
        } catch (Exception ex) {
            Logger.getLogger(ServletBuscar.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * Handles the HTTP <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
     try {
            processRequest(request, response);
        } catch (Exception ex) {
            Logger.getLogger(ServletBuscar.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
}

Como ele ta apresentando um error na linha da declaração do for, é possivel que o listaLançamento esteja nulo e no momento que tenta acessar a função .size(), ele apresenta o nullPointerException.

Tenta conferir se o DAO ta conseguindo realizar a consulta e o preenchimento com sucesso, vi que tem um return null, que pode ser acessado caso ocorra alguma exceção.

Obrigado pela resposta! mais sou nova em programação e estou um pouco perdida

Voce tem acesso ao log da aplicação ?

Se tiver, pesquisa no log por “Erro ao buscar” me diz se encontrar