-1

I am trying to send a report with iReport 5.5.0 Java in NetBeans. I stopped on an error and can not solve the problem. Below is the code and the error.

The Code:

    try {
        Connection con = new ConnectionFactory().getConnection();

        ConectaBanco conecta = new ConectaBanco();
        conecta.conexao();
        PreparedStatement stmt = null;
        String sql = "SELECT l.codigo, l.nome_produto, l.composicao, DATE_FORMAT(l.data_aprovacao , '%d/%m/%Y'), co.nome as colecao, e.nome as estilista, DATE_FORMAT(l.data_inicio , '%d/%m/%Y'), DATE_FORMAT(l.data_termino , '%d/%m/%Y') from lote_producao as l INNER JOIN colecao as co INNER JOIN estilista as e ON co.codigo = l.colecao_codigo AND e.codigo = l.estilista_codigo AND l.codigo = "+codigo;
        stmt = con.prepareStatement(sql);
        ResultSet rs = stmt.executeQuery();
        JRResultSetDataSource relatResult = new JRResultSetDataSource(rs);
        JasperPrint jpPrint = JasperFillManager.fillReport("ireport/relLot.jasper", new HashMap(), relatResult);
        JasperViewer jv = new JasperViewer(jpPrint);
        jv.setVisible(true);
    } catch (SQLException ex) {
        Logger.getLogger(cadastro_lote_1.class.getName()).log(Level.SEVERE, null, ex);
    } catch (JRException ex) {
        Logger.getLogger(cadastro_lote_1.class.getName()).log(Level.SEVERE, null, ex);
    }

The error:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: javax/servlet/ServletOutputStream
at net.sf.jasperreports.web.util.WebResourceHandlersExtensionRegistryFactory.<clinit>(WebResourceHandlersExtensionRegistryFactory.java:47)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForRealName(JRClassLoader.java:157)
at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForName(JRClassLoader.java:115)
Alex K
  • 22,315
  • 19
  • 108
  • 236

1 Answers1

1

Make sure you have imported this.

import javax.servlet.ServletOutputStream;
Chatz
  • 338
  • 2
  • 10