Error in printing Jasper Report



when i click on print option in print dialog box, it throws an error.

My java code is:

        Connection con= DriverManager.getConnection(url, user, pass);
        String report = "/home/rajankit911/eclipse-oxygen-workplace/General/src/testing/Blank_A4.jrxml";
        JasperDesign jd = JRXmlLoader.load(report);
        int id=1;
        String sql = "SELECT * FROM Cust_details where id = "+id;
        JRDesignQuery newQuery = new JRDesignQuery();
        JasperReport jr = JasperCompileManager.compileReport(jd);
        JasperPrint jp = JasperFillManager.fillReport(jr, null, con);
        JasperPrintManager.printReport(jp, true);

Error details are:

Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
Fri Jul 06 13:50:27 IST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See for further details.
Exception in thread "main" net.sf.jasperreports.engine.JRException: Error printing report.
    at net.sf.jasperreports.engine.print.JRPrinterAWT.printPages(
    at net.sf.jasperreports.engine.JasperPrintManager.print(
    at net.sf.jasperreports.engine.JasperPrintManager.print(
    at net.sf.jasperreports.engine.JasperPrintManager.printReport(
    at testing.JDBC.main(
Caused by: java.awt.print.PrinterIOException
    at sun.print.PSPrinterJob$
    at Method)
    at sun.print.PSPrinterJob.endDoc(
    at sun.print.RasterPrinterJob.print(
    at sun.print.RasterPrinterJob.print(
    at net.sf.jasperreports.engine.print.JRPrinterAWT.printPages(
    ... 4 more
Caused by: error=1 running: '/usr/bin/lpr' '-PCanon_MF230' '-JJasperReports - Blank_A4' '/tmp/'
        lpr: Canon_MF230: unknown printer
    at sun.print.PSPrinterJob$PrinterSpooler.handleProcessFailure(
    at sun.print.PSPrinterJob$
    ... 9 more

Please help me to resolve this error.

rajankit420's picture
Joined: Jul 6 2018 - 1:12am
Last seen: 2 years 9 months ago

4 Answers:


It looks like you need add additional dependencies

reportdev's picture
Joined: Oct 12 2015 - 12:05pm
Last seen: 8 months 2 weeks ago

how to add that dependencies??

rajankit420's picture
Joined: Jul 6 2018 - 1:12am
Last seen: 2 years 9 months ago

>Caused by: error=1 running: '/usr/bin/lpr' '-PCanon_MF230' '-JJasperReports - Blank_A4' '/tmp/'

>lpr: Canon_MF230: unknown printer

It looks like error with the printer. Seems like it's not setup properly for linux.

hozawa's picture
Joined: Apr 24 2010 - 4:31pm
Last seen: 1 year 10 months ago

But print command works perfectly when i save the file and then do print.

rajankit420's picture
Joined: Jul 6 2018 - 1:12am
Last seen: 2 years 9 months ago