Cannot invoke "java.io.InputStream.read(byte[], int, int)" because "this.in" is null

Viewed 27

Im trying to make a Jasper Report 5.6.0 file from a button but I ran into this problem:

NullPointerException thrown!java.lang.NullPointerException: Cannot invoke "java.io.InputStream.read(byte[], int, int)" because "this.in" is null

Button Code: var msg = crud.generatepdf("crear"); JOptionPane.showMessageDialog(null, msg);

Method Code:

public String generatepdf(String base) {
 var msg = ""; 
 try{
        JasperPrint jp = JasperFillManager.fillReport(getClass().getResourceAsStream("report1.jasper"), null,
            conect = con.Conexion(base));           
        JasperViewer.viewReport(jp);
    }catch(NullPointerException e) {
System.out.println("NullPointerException thrown!"+ e);
}
    catch(Exception ex){
    System.out.println("Error"+ex);
    }return msg;
    
}

I did many tries and even tried to downgrade code, but is still failing maybe anyone knows how to make it work? or another way to do this issue? Thanks in advance.

0 Answers
Related