Hot questions for Using JasperReports in jdbc

Question:

When creating the reports using DynamicJasper 5.1.1 I am getting resultset from the data source, my pdf if empty after generation, not sure why my pdf is getting empty.

I took the code reference from here. Below is my code:

import ar.com.fdvs.dj.core.DynamicJasperHelper;
import ar.com.fdvs.dj.core.layout.ClassicLayoutManager;
import ar.com.fdvs.dj.domain.DynamicReport;
import ar.com.fdvs.dj.domain.builders.FastReportBuilder;
import net.sf.jasperreports.engine.*;

import java.sql.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class DynamicJDBCReportHandler {

    static String username = "mnbfmwemf";
    static String password = "fwfwfwf";

    public static void main(String[] args) {
        DynamicJDBCReportHandler drh = new DynamicJDBCReportHandler();
        drh.getResultSet();
    }

    public Map<String, Object> getResultSet() {
        Connection connection = null;
        Statement statement = null;
        JasperReport jreport;
        JasperPrint jprint;
        ArrayList<Object> list = new ArrayList<Object>();
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");

            connection = DriverManager.getConnection("jdbc:oracle:thin:@wfwfwf:1521:fwefw", username, password);

            statement = connection.createStatement();

            String query = "SELECT * FROM USER ORDER BY CREATE_DATE";
            ResultSet rs = statement.executeQuery(query);

            JRResultSetDataSource dataSource = new JRResultSetDataSource(rs); // Here associate the resultSet with JasperReport
            FastReportBuilder drb = new FastReportBuilder();
            DynamicReport report = drb.build();

            try {
                jreport = DynamicJasperHelper.generateJasperReport(report, new ClassicLayoutManager(), new HashMap());
                jprint = JasperFillManager.fillReport(jreport, new HashMap<>(), dataSource);
                JasperExportManager.exportReportToPdfFile(jprint, "/report.pdf");
                rs.close();
            } catch (JRException e) {
                e.printStackTrace();
            }
        }catch (ClassNotFoundException | SQLException e) {
            e.printStackTrace();
        } finally {
            try {
                if (statement != null) {
                    statement.close();
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }

            try {
                if (connection != null) {
                    connection.close();
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return  null;
    }
}

I don't want to create .jrxm file or .jasper file, I am sure someone should have done this if you could point me when I am doing wrong, much appreciated your help.


Answer:

What is wrong?

You forgot to declare structure of report with help of FastReportBuilder. You created blank report with this line of code: DynamicReport report = drb.build();.

The right example:

public void buildReport() {
    String query = "SELECT * FROM my_table";
    try (Connection connection = DriverManager.getConnection(getConnectionString(), user, password);
         Statement statement = connection.createStatement();
         ResultSet rs = statement.executeQuery(query)) {

        JRResultSetDataSource dataSource = new JRResultSetDataSource(rs);
        DynamicReport report = new FastReportBuilder().addColumn("Column1", "column_1", String.class.getName(), 120).setTitle("Sample report").build();

        JasperReport jasperReport = DynamicJasperHelper.generateJasperReport(report, new ClassicLayoutManager(), new HashMap());
        JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap<>(), dataSource);
        JasperExportManager.exportReportToPdfFile(jasperPrint, "./report.pdf");
    } catch (SQLException | JRException | ClassNotFoundException e) {
        log.error("Failed to build report", e);
    }
}

I added column Column1 and added title for report with this line of code:

DynamicReport report = new FastReportBuilder().addColumn("Column1", "column_1", String.class.getName(), 120).setTitle("Sample report").build();

More information:

DynamicJasper Getting Started guide

DynamicJasper tests

Question:

I have a jrxml report file designed in jasper studio:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Sample_Blue_Table_Based" pageWidth="842" pageHeight="595" whenNoDataType="AllSectionsNoDetail" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="d4a1d5eb-82dd-412f-a620-202e4bdf9dba">
    <property name="template.engine" value="tabular_template"/>
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="MyDBServer"/>
    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
    <style name="Table">
        <box>
            <pen lineWidth="1.0" lineColor="#000000"/>
            <topPen lineWidth="1.0" lineColor="#000000"/>
            <leftPen lineWidth="1.0" lineColor="#000000"/>
            <bottomPen lineWidth="1.0" lineColor="#000000"/>
            <rightPen lineWidth="1.0" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_TH" mode="Transparent" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_CH" mode="Transparent" forecolor="#B89F7D" backcolor="#70A9C6">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_TD" mode="Transparent" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <subDataset name="tableDataset" uuid="d126342f-2c37-4323-99a6-4d0a9542aa8a">
        <property name="com.jaspersoft.studio.data.defaultdataadapter" value="MyDBServer"/>
        <queryString language="SQL">
            <![CDATA[select * from users]]>
        </queryString>
        <field name="id" class="java.lang.Integer">
            <property name="com.jaspersoft.studio.field.label" value="id"/>
            <property name="com.jaspersoft.studio.field.tree.path" value="users"/>
        </field>
        <field name="created_at" class="java.sql.Timestamp">
            <property name="com.jaspersoft.studio.field.label" value="created_at"/>
            <property name="com.jaspersoft.studio.field.tree.path" value="users"/>
        </field>
        <field name="email" class="java.lang.String">
            <property name="com.jaspersoft.studio.field.label" value="email"/>
            <property name="com.jaspersoft.studio.field.tree.path" value="users"/>
        </field>
        <field name="firstName" class="java.lang.String">
            <property name="com.jaspersoft.studio.field.label" value="firstName"/>
            <property name="com.jaspersoft.studio.field.tree.path" value="users"/>
        </field>
        <field name="lastName" class="java.lang.String">
            <property name="com.jaspersoft.studio.field.label" value="lastName"/>
            <property name="com.jaspersoft.studio.field.tree.path" value="users"/>
        </field>
        <field name="updated_at" class="java.sql.Timestamp">
            <property name="com.jaspersoft.studio.field.label" value="updated_at"/>
            <property name="com.jaspersoft.studio.field.tree.path" value="users"/>
        </field>
        <field name="username" class="java.lang.String">
            <property name="com.jaspersoft.studio.field.label" value="username"/>
            <property name="com.jaspersoft.studio.field.tree.path" value="users"/>
        </field>
        <field name="status" class="java.lang.Boolean">
            <property name="com.jaspersoft.studio.field.label" value="status"/>
            <property name="com.jaspersoft.studio.field.tree.path" value="users"/>
        </field>
    </subDataset>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <title>
        <band height="72">
            <frame>
                <reportElement mode="Opaque" x="-20" y="-20" width="842" height="92" backcolor="#4AC416" uuid="6321f5e3-86eb-444f-acc1-8daaaa0d6c60"/>
                <staticText>
                    <reportElement x="20" y="20" width="320" height="43" forecolor="#FFFFFF" uuid="9e48917a-7b59-4ffd-baad-725f45563194"/>
                    <textElement>
                        <font size="34" isBold="true"/>
                    </textElement>
                    <text><![CDATA[Admin App Users]]></text>
                </staticText>
                <staticText>
                    <reportElement x="650" y="46" width="180" height="20" forecolor="#FFFFFF" uuid="0a399baa-bad3-4b1a-9fe3-bb1c563e6a27"/>
                    <textElement textAlignment="Right">
                        <font size="14" isBold="false"/>
                    </textElement>
                    <text><![CDATA[Application Users Report]]></text>
                </staticText>
            </frame>
        </band>
    </title>
    <pageHeader>
        <band height="13"/>
    </pageHeader>
    <pageFooter>
        <band height="17">
            <textField>
                <reportElement mode="Opaque" x="0" y="4" width="515" height="13" backcolor="#E6E6E6" uuid="fed27553-a6c4-4a8a-9056-2f6f2589a3e5"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
            </textField>
            <textField evaluationTime="Report">
                <reportElement mode="Opaque" x="515" y="4" width="40" height="13" backcolor="#E6E6E6" uuid="9f5ad531-d413-49c9-874b-8b99e8150fa6"/>
                <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
            </textField>
            <textField pattern="EEEEE dd MMMMM yyyy">
                <reportElement x="0" y="4" width="100" height="13" uuid="fc593335-5cbf-4caf-97b3-ff897c676bde"/>
                <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
            </textField>
        </band>
    </pageFooter>
    <summary>
        <band height="200" splitType="Stretch">
            <property name="local_mesure_unitheight" value="pixel"/>
            <componentElement>
                <reportElement x="0" y="0" width="806" height="200" uuid="01fed4d0-1b62-44ff-9fa5-e47ff6987d68">
                    <property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/>
                    <property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/>
                    <property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/>
                </reportElement>
                <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
                    <datasetRun subDataset="tableDataset" uuid="2ad3f0b0-b1fd-40d9-a08f-170bf2519948">
                        <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                    </datasetRun>
                    <jr:column width="60" uuid="99ec822c-fb05-4f72-abd4-5f009620a549">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/>
                        <jr:tableHeader style="Table_TH" height="30" rowSpan="1"/>
                        <jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement mode="Transparent" x="0" y="0" width="60" height="30" forecolor="#006699" backcolor="#E6E6E6" uuid="06b3eded-dc90-4b57-9d0e-c51c6f342892"/>
                                <textElement textAlignment="Center">
                                    <font size="14" isBold="true"/>
                                </textElement>
                                <text><![CDATA[ID]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement key="" x="0" y="0" width="60" height="30" uuid="19c36999-b01b-4bbd-a41e-c53ae0c80afd"/>
                                <box leftPadding="2"/>
                                <textElement textAlignment="Center">
                                    <font fontName="Arial" size="14"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{id}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="140" uuid="2483833e-c55e-4a69-8868-9b08db7559c0">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column4"/>
                        <jr:tableHeader style="Table_TH" height="30" rowSpan="1"/>
                        <jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement mode="Transparent" x="0" y="0" width="140" height="30" forecolor="#006699" backcolor="#E6E6E6" uuid="9c786800-8901-47ae-bd4a-3c01204abd4d"/>
                                <textElement textAlignment="Center">
                                    <font size="14" isBold="true"/>
                                </textElement>
                                <text><![CDATA[First Name]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement key="" x="0" y="0" width="140" height="30" uuid="d7b6cf06-c37f-4ec1-a519-3e7fe2d7be8b"/>
                                <box leftPadding="2"/>
                                <textElement>
                                    <font fontName="Arial" size="14"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{firstName}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="140" uuid="8d185e10-164e-420a-8a7f-d159ff9cb691">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column5"/>
                        <jr:tableHeader style="Table_TH" height="30" rowSpan="1"/>
                        <jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement mode="Transparent" x="0" y="0" width="140" height="30" forecolor="#006699" backcolor="#E6E6E6" uuid="946eda2c-149c-4eb4-a929-cca937fb6393"/>
                                <textElement textAlignment="Center">
                                    <font size="14" isBold="true"/>
                                </textElement>
                                <text><![CDATA[Last Name]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement key="" x="0" y="0" width="140" height="30" uuid="09d3f107-6c04-4587-bf7a-91e871ce4f3b"/>
                                <box leftPadding="2"/>
                                <textElement>
                                    <font fontName="Arial" size="14"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{lastName}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="130" uuid="395a497b-e0fc-4850-9f10-e41d4fd41035">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column6"/>
                        <jr:tableHeader style="Table_TH" height="30" rowSpan="1"/>
                        <jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement mode="Transparent" x="0" y="0" width="130" height="30" forecolor="#006699" backcolor="#E6E6E6" uuid="1912c136-2a05-4089-ae91-54a5d815bc92"/>
                                <textElement textAlignment="Center">
                                    <font size="14" isBold="true"/>
                                </textElement>
                                <text><![CDATA[Username]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement key="" x="0" y="0" width="130" height="30" uuid="cb9efd41-06b7-4059-a6ec-0fb35ccdbbc2"/>
                                <box leftPadding="2"/>
                                <textElement textAlignment="Left">
                                    <font fontName="Arial" size="14"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{username}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="160" uuid="3c37b453-c14e-41af-af30-696eac992472">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column3"/>
                        <jr:tableHeader style="Table_TH" height="30" rowSpan="1"/>
                        <jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement mode="Transparent" x="0" y="0" width="160" height="30" forecolor="#006699" backcolor="#E6E6E6" uuid="58e2962c-e1f6-4649-8bd3-3e410fa58674"/>
                                <textElement textAlignment="Center">
                                    <font size="14" isBold="true"/>
                                </textElement>
                                <text><![CDATA[Email]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement key="" x="0" y="0" width="160" height="30" uuid="702a303c-9c29-4119-8156-8eb9bac28b7d"/>
                                <box leftPadding="2"/>
                                <textElement textAlignment="Left">
                                    <font fontName="Arial" size="14"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{email}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="50" uuid="5a8d7002-6adc-4cff-9e7e-132ed9316b8e">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column7"/>
                        <jr:tableHeader style="Table_TH" height="30" rowSpan="1"/>
                        <jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement mode="Transparent" x="0" y="0" width="50" height="30" forecolor="#006699" backcolor="#E6E6E6" uuid="9ec69fab-1e14-49cf-ab25-1e8b037da361"/>
                                <textElement textAlignment="Center">
                                    <font size="14" isBold="true"/>
                                </textElement>
                                <text><![CDATA[A]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement key="" x="0" y="0" width="50" height="30" uuid="abfefc2d-93c3-4d65-afdc-5e9304224a32"/>
                                <box leftPadding="2"/>
                                <textElement textAlignment="Center">
                                    <font fontName="Arial" size="14"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{status}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="120" uuid="1af5f085-9784-49d9-b3b8-17cf34f4ac84">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/>
                        <jr:tableHeader style="Table_TH" height="30" rowSpan="1"/>
                        <jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement mode="Transparent" x="0" y="0" width="120" height="30" forecolor="#006699" backcolor="#E6E6E6" uuid="fd3401b4-a35c-435b-9c9c-9ba9840db3b8"/>
                                <textElement textAlignment="Center">
                                    <font size="14" isBold="true"/>
                                </textElement>
                                <text><![CDATA[Created At]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement key="" x="0" y="0" width="120" height="30" uuid="9147c910-e8b4-4a79-8225-ea490c1de8a9"/>
                                <box leftPadding="2"/>
                                <textElement>
                                    <font fontName="Arial" size="14"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{created_at}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                </jr:table>
            </componentElement>
        </band>
    </summary>
</jasperReport>

I followed the link here to integrate it with sprint boot app

Jasper report in spring framework and spring JPA

I have the following error when i run the app and a blank report.

Pleasssssssse help me integrate report generated from studio to spring boot.

(I am a java newbie)

here is my report controller method

@RequestMapping( method = RequestMethod.GET)
    public void report(HttpServletResponse response) throws Exception {
        response.setContentType("text/html");
        JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(userReportService.report());
        InputStream inputStream = this.getClass().getResourceAsStream("/reports/users_report.jrxml");
        JasperReport jasperReport = JasperCompileManager.compileReport(inputStream);
        JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, dataSource);
        HtmlExporter exporter = new HtmlExporter(DefaultJasperReportsContext.getInstance());
        exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
        exporter.setExporterOutput(new SimpleHtmlExporterOutput(response.getWriter()));
        exporter.exportReport();
    }

Am passing a json data as the data source


Answer:

I found the solution in this stackoverflow question the steps as highlighted in the answer are:

  1. Send your datasource from the server as a parameter, and fill the report with a different one (can be empty).
  2. Declare a new parameter in the report of type JRBeanCollectionDataSource
  3. Set TableDatasource to use the $P{DS1} parameter.
  4. ...

In addition, i modified my report file field declarations and remove all jasper studio properties there.

After following this steps and modifying my report file and controller, it worked. Here is my new controller method:

public void report(HttpServletResponse response) throws Exception {
    response.setContentType("text/html");
    List data = userReportService.report();
    JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(data);
    Map parameters = new HashMap();
    parameters.put("test", data.get(0));
    parameters.put("DS1", dataSource);
    InputStream inputStream = this.getClass().getResourceAsStream("/reports/users_report.jrxml");
    JasperReport jasperReport = JasperCompileManager.compileReport(inputStream);
    JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, new JREmptyDataSource());
    HtmlExporter exporter = new HtmlExporter(DefaultJasperReportsContext.getInstance());
    exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
    exporter.setExporterOutput(new SimpleHtmlExporterOutput(response.getWriter()));
    exporter.exportReport();
}

And my new jrxml file is this:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Sample_Blue_Table_Based" pageWidth="842" pageHeight="595" whenNoDataType="AllSectionsNoDetail" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="d4a1d5eb-82dd-412f-a620-202e4bdf9dba">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
    <style name="Table">
        <box>
            <pen lineWidth="1.0" lineColor="#000000"/>
            <topPen lineWidth="1.0" lineColor="#000000"/>
            <leftPen lineWidth="1.0" lineColor="#000000"/>
            <bottomPen lineWidth="1.0" lineColor="#000000"/>
            <rightPen lineWidth="1.0" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_TH" mode="Transparent" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_CH" mode="Transparent" forecolor="#B89F7D" backcolor="#70A9C6">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_TD" mode="Transparent" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <subDataset name="tableDataset" uuid="d126342f-2c37-4323-99a6-4d0a9542aa8a">
        <queryString language="json">
            <![CDATA[]]>
        </queryString>
        <field name="id" class="java.lang.Integer"/>
        <field name="firstName" class="java.lang.String"/>
        <field name="lastName" class="java.lang.String"/>
        <field name="username" class="java.lang.String"/>
        <field name="email" class="java.lang.String"/>
        <field name="status" class="java.lang.Boolean"/>
        <field name="created_at" class="java.sql.Timestamp"/>
    </subDataset>
    <parameter name="DS1" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
    <title>
        <band height="72">
            <frame>
                <reportElement mode="Opaque" x="-20" y="-20" width="842" height="92" backcolor="#4AC416" uuid="6321f5e3-86eb-444f-acc1-8daaaa0d6c60"/>
                <staticText>
                    <reportElement x="20" y="20" width="320" height="43" forecolor="#FFFFFF" uuid="9e48917a-7b59-4ffd-baad-725f45563194"/>
                    <textElement>
                        <font size="34" isBold="true"/>
                    </textElement>
                    <text><![CDATA[Admin App Users]]></text>
                </staticText>
                <staticText>
                    <reportElement x="650" y="46" width="180" height="20" forecolor="#FFFFFF" uuid="0a399baa-bad3-4b1a-9fe3-bb1c563e6a27"/>
                    <textElement textAlignment="Right">
                        <font size="14" isBold="false"/>
                    </textElement>
                    <text><![CDATA[Application Users Report]]></text>
                </staticText>
            </frame>
        </band>
    </title>
    <pageHeader>
        <band height="13"/>
    </pageHeader>
    <pageFooter>
        <band height="17">
            <textField>
                <reportElement mode="Opaque" x="0" y="4" width="760" height="13" backcolor="#E6E6E6" uuid="fed27553-a6c4-4a8a-9056-2f6f2589a3e5"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
            </textField>
            <textField evaluationTime="Report">
                <reportElement mode="Opaque" x="762" y="4" width="40" height="13" backcolor="#E6E6E6" uuid="9f5ad531-d413-49c9-874b-8b99e8150fa6"/>
                <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
            </textField>
            <textField pattern="EEEEE dd MMMMM yyyy">
                <reportElement x="0" y="4" width="100" height="13" uuid="fc593335-5cbf-4caf-97b3-ff897c676bde"/>
                <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
            </textField>
        </band>
    </pageFooter>
    <summary>
        <band height="200" splitType="Stretch">
            <property name="local_mesure_unitheight" value="pixel"/>
            <componentElement>
                <reportElement x="0" y="0" width="806" height="200" uuid="01fed4d0-1b62-44ff-9fa5-e47ff6987d68">
                    <property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/>
                    <property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/>
                    <property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/>
                </reportElement>
                <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
                    <datasetRun subDataset="tableDataset" uuid="ee7a04e1-1abd-4fc2-baf5-52183f1eaa43">
                        <datasetParameter name="REPORT_DATA_SOURCE">
                            <datasetParameterExpression><![CDATA[$P{DS1}]]></datasetParameterExpression>
                        </datasetParameter>
                    </datasetRun>
                    <jr:column width="60" uuid="99ec822c-fb05-4f72-abd4-5f009620a549">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/>
                        <jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement mode="Transparent" x="0" y="0" width="60" height="30" forecolor="#006699" backcolor="#E6E6E6" uuid="06b3eded-dc90-4b57-9d0e-c51c6f342892"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font size="14" isBold="true"/>
                                </textElement>
                                <text><![CDATA[ID]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement key="" x="0" y="0" width="60" height="30" uuid="19c36999-b01b-4bbd-a41e-c53ae0c80afd"/>
                                <box leftPadding="2"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font fontName="Arial" size="14"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{id}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="140" uuid="2483833e-c55e-4a69-8868-9b08db7559c0">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/>
                        <jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement mode="Transparent" x="0" y="0" width="140" height="30" forecolor="#006699" backcolor="#E6E6E6" uuid="9c786800-8901-47ae-bd4a-3c01204abd4d"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font size="14" isBold="true"/>
                                </textElement>
                                <text><![CDATA[First Name]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement key="" x="0" y="0" width="140" height="30" uuid="d7b6cf06-c37f-4ec1-a519-3e7fe2d7be8b"/>
                                <box leftPadding="2"/>
                                <textElement verticalAlignment="Middle">
                                    <font fontName="Arial" size="14"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{firstName}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="140" uuid="8d185e10-164e-420a-8a7f-d159ff9cb691">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column3"/>
                        <jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement mode="Transparent" x="0" y="0" width="140" height="30" forecolor="#006699" backcolor="#E6E6E6" uuid="946eda2c-149c-4eb4-a929-cca937fb6393"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font size="14" isBold="true"/>
                                </textElement>
                                <text><![CDATA[Last Name]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement key="" x="0" y="0" width="140" height="30" uuid="09d3f107-6c04-4587-bf7a-91e871ce4f3b"/>
                                <box leftPadding="2"/>
                                <textElement verticalAlignment="Middle">
                                    <font fontName="Arial" size="14"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{lastName}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="130" uuid="395a497b-e0fc-4850-9f10-e41d4fd41035">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column4"/>
                        <jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement mode="Transparent" x="0" y="0" width="130" height="30" forecolor="#006699" backcolor="#E6E6E6" uuid="1912c136-2a05-4089-ae91-54a5d815bc92"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font size="14" isBold="true"/>
                                </textElement>
                                <text><![CDATA[Username]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement key="" x="0" y="0" width="130" height="30" uuid="cb9efd41-06b7-4059-a6ec-0fb35ccdbbc2"/>
                                <box leftPadding="2"/>
                                <textElement textAlignment="Left" verticalAlignment="Middle">
                                    <font fontName="Arial" size="14"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{username}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="160" uuid="3c37b453-c14e-41af-af30-696eac992472">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column5"/>
                        <jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement mode="Transparent" x="0" y="0" width="160" height="30" forecolor="#006699" backcolor="#E6E6E6" uuid="58e2962c-e1f6-4649-8bd3-3e410fa58674"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font size="14" isBold="true"/>
                                </textElement>
                                <text><![CDATA[Email]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement key="" x="0" y="0" width="160" height="30" uuid="702a303c-9c29-4119-8156-8eb9bac28b7d"/>
                                <box leftPadding="2"/>
                                <textElement textAlignment="Left" verticalAlignment="Middle">
                                    <font fontName="Arial" size="14"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{email}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="50" uuid="5a8d7002-6adc-4cff-9e7e-132ed9316b8e">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column6"/>
                        <jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement mode="Transparent" x="0" y="0" width="50" height="30" forecolor="#006699" backcolor="#E6E6E6" uuid="9ec69fab-1e14-49cf-ab25-1e8b037da361"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font size="14" isBold="true"/>
                                </textElement>
                                <text><![CDATA[A]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement key="" x="0" y="0" width="50" height="30" uuid="abfefc2d-93c3-4d65-afdc-5e9304224a32"/>
                                <box leftPadding="2"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font fontName="Arial" size="14"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{status}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="120" uuid="1af5f085-9784-49d9-b3b8-17cf34f4ac84">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column7"/>
                        <jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement mode="Transparent" x="0" y="0" width="120" height="30" forecolor="#006699" backcolor="#E6E6E6" uuid="fd3401b4-a35c-435b-9c9c-9ba9840db3b8"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font size="14" isBold="true"/>
                                </textElement>
                                <text><![CDATA[Created At]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement key="" x="0" y="0" width="120" height="30" uuid="9147c910-e8b4-4a79-8225-ea490c1de8a9"/>
                                <box leftPadding="2"/>
                                <textElement verticalAlignment="Middle">
                                    <font fontName="Arial" size="14"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{created_at}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                </jr:table>
            </componentElement>
        </band>
    </summary>
</jasperReport>

I hope this saves a newbie like me some headache and thanks to @PetterFriberg

Question:

EDIT: Originally the question was on "compilation breakes down", but it's more accurate to say "on application contex load"

I'm working on an billing system. As part of the next iteration, I need to create an invoice document.

We're making this with Jasper Reports. The "design" of the document was made and approved with Jasperstudio (we will load the .jasper compiled file).

The problem comes when I add the jasperreports dependency (no new classes nor new code anywhere).

When I run my cucumber test for the creation of the invoice I got this during the autowiring of one of my Spring repositories:

Internal Exception: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/my_database

I do depend directly from mysql-connector-java (6.0.6) and I had no problems before this.

I assume it's a dependency problem, but I can't find it.

This is my dependency tree

[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building Billing-Server 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ billing-server ---
[INFO] com.company:billing-server:war:0.0.1-SNAPSHOT
[INFO] +- org.springframework:spring-webmvc:jar:4.3.8.RELEASE:compile
[INFO] |  +- (org.springframework:spring-aop:jar:4.3.8.RELEASE:compile - omitted for duplicate)
[INFO] |  +- org.springframework:spring-beans:jar:4.3.8.RELEASE:compile
[INFO] |  |  \- (org.springframework:spring-core:jar:4.3.8.RELEASE:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-context:jar:4.3.8.RELEASE:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-core:jar:4.3.8.RELEASE:compile - omitted for duplicate)
[INFO] |  +- org.springframework:spring-expression:jar:4.3.8.RELEASE:compile
[INFO] |  |  \- (org.springframework:spring-core:jar:4.3.8.RELEASE:compile - omitted for duplicate)
[INFO] |  \- org.springframework:spring-web:jar:4.3.8.RELEASE:compile
[INFO] |     +- (org.springframework:spring-aop:jar:4.3.8.RELEASE:compile - omitted for duplicate)
[INFO] |     +- (org.springframework:spring-beans:jar:4.3.8.RELEASE:compile - omitted for duplicate)
[INFO] |     +- (org.springframework:spring-context:jar:4.3.8.RELEASE:compile - omitted for duplicate)
[INFO] |     \- (org.springframework:spring-core:jar:4.3.8.RELEASE:compile - omitted for duplicate)
[INFO] +- org.springframework.data:spring-data-jpa:jar:1.9.1.RELEASE:compile
[INFO] |  +- org.springframework.data:spring-data-commons:jar:1.11.1.RELEASE:compile
[INFO] |  |  +- (org.springframework:spring-core:jar:4.1.8.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  |  +- (org.springframework:spring-beans:jar:4.1.8.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  |  +- (org.slf4j:slf4j-api:jar:1.7.13:compile - omitted for duplicate)
[INFO] |  |  \- (org.slf4j:jcl-over-slf4j:jar:1.7.13:runtime - omitted for duplicate)
[INFO] |  +- org.springframework:spring-orm:jar:4.1.8.RELEASE:compile
[INFO] |  |  +- (org.springframework:spring-beans:jar:4.1.8.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  |  +- (org.springframework:spring-core:jar:4.1.8.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  |  +- org.springframework:spring-jdbc:jar:4.1.8.RELEASE:compile
[INFO] |  |  |  +- (org.springframework:spring-beans:jar:4.1.8.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  |  |  +- (org.springframework:spring-core:jar:4.1.8.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  |  |  \- (org.springframework:spring-tx:jar:4.1.8.RELEASE:compile - omitted for duplicate)
[INFO] |  |  \- (org.springframework:spring-tx:jar:4.1.8.RELEASE:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-context:jar:4.1.8.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  +- (org.springframework:spring-aop:jar:4.1.8.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  +- org.springframework:spring-tx:jar:4.1.8.RELEASE:compile
[INFO] |  |  +- (org.springframework:spring-beans:jar:4.1.8.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  |  \- (org.springframework:spring-core:jar:4.1.8.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  +- (org.springframework:spring-beans:jar:4.1.8.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  +- (org.springframework:spring-core:jar:4.1.8.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  +- (org.aspectj:aspectjrt:jar:1.8.7:compile - omitted for conflict with 1.8.13)
[INFO] |  +- org.slf4j:slf4j-api:jar:1.7.13:compile
[INFO] |  \- org.slf4j:jcl-over-slf4j:jar:1.7.13:runtime
[INFO] |     \- (org.slf4j:slf4j-api:jar:1.7.13:runtime - omitted for duplicate)
[INFO] +- org.springframework.security:spring-security-core:jar:4.0.1.RELEASE:compile
[INFO] |  +- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  +- (org.springframework:spring-aop:jar:4.1.6.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  +- (org.springframework:spring-beans:jar:4.1.6.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  +- (org.springframework:spring-context:jar:4.1.6.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  +- (org.springframework:spring-core:jar:4.1.6.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  \- (org.springframework:spring-expression:jar:4.1.6.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] +- org.springframework.security:spring-security-config:jar:4.0.1.RELEASE:compile
[INFO] |  +- (aopalliance:aopalliance:jar:1.0:compile - omitted for duplicate)
[INFO] |  +- (org.springframework.security:spring-security-core:jar:4.0.1.RELEASE:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-aop:jar:4.1.6.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  +- (org.springframework:spring-beans:jar:4.1.6.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  +- (org.springframework:spring-context:jar:4.1.6.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  \- (org.springframework:spring-core:jar:4.1.6.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] +- org.springframework.security:spring-security-web:jar:4.0.1.RELEASE:compile
[INFO] |  +- (aopalliance:aopalliance:jar:1.0:compile - omitted for duplicate)
[INFO] |  +- (org.springframework.security:spring-security-core:jar:4.0.1.RELEASE:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-beans:jar:4.1.6.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  +- (org.springframework:spring-context:jar:4.1.6.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  +- (org.springframework:spring-core:jar:4.1.6.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  +- (org.springframework:spring-expression:jar:4.1.6.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  \- (org.springframework:spring-web:jar:4.1.6.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] +- org.eclipse.persistence:eclipselink:jar:2.6.4:compile
[INFO] |  +- org.eclipse.persistence:javax.persistence:jar:2.1.1:compile
[INFO] |  +- org.eclipse.persistence:commonj.sdo:jar:2.1.1:compile
[INFO] |  +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] |  \- org.glassfish:javax.json:jar:1.0.4:compile
[INFO] +- commons-validator:commons-validator:jar:1.6:compile
[INFO] |  +- commons-beanutils:commons-beanutils:jar:1.9.2:compile
[INFO] |  |  +- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for conflict with 1.2)
[INFO] |  |  \- (commons-collections:commons-collections:jar:3.2.1:compile - omitted for conflict with 3.2.2)
[INFO] |  +- commons-digester:commons-digester:jar:1.8.1:compile
[INFO] |  +- commons-logging:commons-logging:jar:1.2:compile
[INFO] |  \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] +- com.sun.mail:javax.mail:jar:1.6.1:compile
[INFO] |  \- javax.activation:activation:jar:1.1:compile
[INFO] +- org.springframework.batch:spring-batch-core:jar:3.0.7.RELEASE:compile
[INFO] |  +- com.ibm.jbatch:com.ibm.jbatch-tck-spi:jar:1.0:compile
[INFO] |  |  \- javax.batch:javax.batch-api:jar:1.0:compile
[INFO] |  +- com.thoughtworks.xstream:xstream:jar:1.4.7:compile
[INFO] |  |  +- xmlpull:xmlpull:jar:1.1.3.1:compile
[INFO] |  |  \- xpp3:xpp3_min:jar:1.1.4c:compile
[INFO] |  +- org.codehaus.jettison:jettison:jar:1.2:compile
[INFO] |  +- org.springframework.batch:spring-batch-infrastructure:jar:3.0.7.RELEASE:compile
[INFO] |  |  \- org.springframework.retry:spring-retry:jar:1.1.0.RELEASE:compile
[INFO] |  |     \- (org.springframework:spring-context:jar:4.0.3.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  +- (org.springframework:spring-aop:jar:4.0.5.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  +- (org.springframework:spring-beans:jar:4.0.5.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  +- (org.springframework:spring-context:jar:4.0.5.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  +- (org.springframework:spring-core:jar:4.0.5.RELEASE:compile - omitted for conflict with 4.3.8.RELEASE)
[INFO] |  \- (org.springframework:spring-tx:jar:4.0.5.RELEASE:compile - omitted for conflict with 4.1.8.RELEASE)
[INFO] +- net.sf.jasperreports:jasperreports:jar:6.5.1:compile
[INFO] |  +- (commons-beanutils:commons-beanutils:jar:1.9.3:compile - omitted for conflict with 1.9.2)
[INFO] |  +- (commons-collections:commons-collections:jar:3.2.2:compile - omitted for duplicate)
[INFO] |  +- (commons-digester:commons-digester:jar:2.1:compile - omitted for conflict with 1.8.1)
[INFO] |  +- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for conflict with 1.2)
[INFO] |  +- com.lowagie:itext:jar:2.1.7.js6:compile
[INFO] |  |  \- org.bouncycastle:bcprov-jdk15on:jar:1.52:compile
[INFO] |  +- org.jfree:jcommon:jar:1.0.23:compile
[INFO] |  +- org.jfree:jfreechart:jar:1.0.19:compile
[INFO] |  |  \- (org.jfree:jcommon:jar:1.0.23:compile - omitted for duplicate)
[INFO] |  +- org.eclipse.jdt.core.compiler:ecj:jar:4.4.2:compile
[INFO] |  +- org.codehaus.castor:castor-xml:jar:1.3.3:compile
[INFO] |  |  +- org.codehaus.castor:castor-core:jar:1.3.3:compile
[INFO] |  |  |  +- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for conflict with 1.2)
[INFO] |  |  |  \- (commons-lang:commons-lang:jar:2.6:compile - omitted for duplicate)
[INFO] |  |  +- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for conflict with 1.2)
[INFO] |  |  +- commons-lang:commons-lang:jar:2.6:compile
[INFO] |  |  +- (commons-collections:commons-collections:jar:3.2.1:compile - omitted for conflict with 3.2.2)
[INFO] |  |  +- javax.inject:javax.inject:jar:1:compile
[INFO] |  |  +- stax:stax:jar:1.2.0:compile
[INFO] |  |  |  \- stax:stax-api:jar:1.0.1:compile
[INFO] |  |  \- javax.xml.stream:stax-api:jar:1.0-2:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-core:jar:2.1.4:compile
[INFO] |  +- (com.fasterxml.jackson.core:jackson-databind:jar:2.1.4:compile - omitted for conflict with 2.9.3)
[INFO] |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.1.4:compile
[INFO] |  +- org.apache.lucene:lucene-core:jar:4.5.1:compile
[INFO] |  +- org.apache.lucene:lucene-analyzers-common:jar:4.5.1:compile
[INFO] |  |  \- (org.apache.lucene:lucene-core:jar:4.5.1:compile - omitted for duplicate)
[INFO] |  +- org.apache.lucene:lucene-queryparser:jar:4.5.1:compile
[INFO] |  |  +- (org.apache.lucene:lucene-core:jar:4.5.1:compile - omitted for duplicate)
[INFO] |  |  +- org.apache.lucene:lucene-queries:jar:4.5.1:compile
[INFO] |  |  |  \- (org.apache.lucene:lucene-core:jar:4.5.1:compile - omitted for duplicate)
[INFO] |  |  \- org.apache.lucene:lucene-sandbox:jar:4.5.1:compile
[INFO] |  |     +- (org.apache.lucene:lucene-core:jar:4.5.1:compile - omitted for duplicate)
[INFO] |  |     \- jakarta-regexp:jakarta-regexp:jar:1.4:compile
[INFO] |  +- org.olap4j:olap4j:jar:0.9.7.309-JS-3:compile
[INFO] |  +- com.google.zxing:core:jar:3.2.1:compile
[INFO] |  \- com.ibm.icu:icu4j:jar:57.1:compile
[INFO] +- org.springframework:spring-aop:jar:4.3.8.RELEASE:compile
[INFO] |  +- (org.springframework:spring-beans:jar:4.3.8.RELEASE:compile - omitted for duplicate)
[INFO] |  \- (org.springframework:spring-core:jar:4.3.8.RELEASE:compile - omitted for duplicate)
[INFO] +- org.aspectj:aspectjrt:jar:1.8.13:compile
[INFO] +- org.aspectj:aspectjweaver:jar:1.8.13:compile
[INFO] +- javax.servlet:javax.servlet-api:jar:4.0.0-b06:provided
[INFO] +- mysql:mysql-connector-java:jar:6.0.6:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.2.3:test
[INFO] |  +- ch.qos.logback:logback-core:jar:1.2.3:test
[INFO] |  \- (org.slf4j:slf4j-api:jar:1.7.25:test - omitted for conflict with 1.7.13)
[INFO] +- org.springframework:spring-core:jar:4.3.8.RELEASE:compile
[INFO] |  \- (commons-logging:commons-logging:jar:1.2:compile - omitted for duplicate)
[INFO] +- org.springframework:spring-context:jar:4.3.8.RELEASE:compile
[INFO] |  +- (org.springframework:spring-aop:jar:4.3.8.RELEASE:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-beans:jar:4.3.8.RELEASE:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-core:jar:4.3.8.RELEASE:compile - omitted for duplicate)
[INFO] |  \- (org.springframework:spring-expression:jar:4.3.8.RELEASE:compile - omitted for duplicate)
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.3:compile
[INFO] |  +- (com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile - omitted for conflict with 2.1.4)
[INFO] |  \- (com.fasterxml.jackson.core:jackson-core:jar:2.9.3:compile - omitted for conflict with 2.1.4)
[INFO] +- org.exparity:hamcrest-date:jar:2.0.4:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.springframework:spring-test:jar:4.3.8.RELEASE:test
[INFO] |  \- (org.springframework:spring-core:jar:4.3.8.RELEASE:test - omitted for duplicate)
[INFO] +- junit:junit:jar:4.12:test
[INFO] |  \- (org.hamcrest:hamcrest-core:jar:1.3:test - omitted for duplicate)
[INFO] +- io.cucumber:cucumber-java:jar:2.1.0:test
[INFO] |  \- io.cucumber:cucumber-core:jar:2.1.0:test
[INFO] |     +- info.cukes:cucumber-html:jar:0.2.6:test
[INFO] |     +- io.cucumber:cucumber-jvm-deps:jar:1.0.6:test
[INFO] |     +- io.cucumber:gherkin:jar:5.0.0:test
[INFO] |     \- io.cucumber:tag-expressions:jar:1.0.1:test
[INFO] +- io.cucumber:cucumber-junit:jar:2.1.0:test
[INFO] |  +- (io.cucumber:cucumber-core:jar:2.1.0:test - omitted for duplicate)
[INFO] |  \- (junit:junit:jar:4.12:test - omitted for duplicate)
[INFO] +- info.cukes:cucumber-spring:jar:1.2.5:test
[INFO] |  \- info.cukes:cucumber-java:jar:1.2.5:test
[INFO] |     \- info.cukes:cucumber-core:jar:1.2.5:test
[INFO] |        +- (info.cukes:cucumber-html:jar:0.2.3:test - omitted for conflict with 0.2.6)
[INFO] |        +- info.cukes:cucumber-jvm-deps:jar:1.0.5:test
[INFO] |        \- info.cukes:gherkin:jar:2.12.2:test
[INFO] \- org.mockito:mockito-core:jar:2.13.0:test
[INFO]    +- net.bytebuddy:byte-buddy:jar:1.7.9:test
[INFO]    +- net.bytebuddy:byte-buddy-agent:jar:1.7.9:test
[INFO]    \- org.objenesis:objenesis:jar:2.6:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.933 s
[INFO] Finished at: 2018-03-01T21:57:35-06:00
[INFO] Final Memory: 18M/244M
[INFO] ------------------------------------------------------------------------

any hint would be appreciated.


Answer:

The problem is solved by moving the dependency down below in the POM.

My guess is that jasperreports does some kind of initialization and needs all dependencies to be already there. But I can't figure out why it might be doing this.

Can anyone explain?

Question:

I'm trying to make a report with JasperReports containing the result of the queries to a database. I followed some tutorials and I wrote the code. The part which the database connection it's ok, it works:

"Get connection ... Get connection oracle.jdbc.driver.************ Done!", but when I'm trying to run the class with the report, I face some exceptions:

1) Exception in thread "main" net.sf.jasperreports.engine.JRException: Error compiling report java source files : E:\Fc\Java\hws\L9again\StyledTextReport_1462019818479_424906.java;

2)Caused by: java.io.IOException: Cannot run program "javac": CreateProcess error=2, The system cannot find the file specified;

3)Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified.

My code for the part with the report is:

package org.o7;
import java.io.File;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import net.sf.jasperreports.engine.JRException; 
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.export.ExporterInput;
import net.sf.jasperreports.export.OutputStreamExporterOutput;
import net.sf.jasperreports.export.SimpleExporterInput;
import net.sf.jasperreports.export.SimpleOutputStreamExporterOutput;
import net.sf.jasperreports.export.SimplePdfExporterConfiguration;

public class JavaCallJasperReport {

public static void main(String[] args) throws JRException,
        ClassNotFoundException, SQLException {

    String reportSrcFile =     "C:/jasperreport/StyledTextReport/StyledTextReport.jrxml";

    // First, compile jrxml file.
    JasperReport jasperReport =   JasperCompileManager.compileReport(reportSrcFile);

    Connection conn = ConnectionUtils.getConnection();

    // Parameters for report
    Map<String, Object> parameters = new HashMap<String, Object>();

    JasperPrint print = JasperFillManager.fillReport(jasperReport,
            parameters, conn);

    // Make sure the output directory exists.
    File outDir = new File("C:/jasperoutput");
    outDir.mkdirs();

    // PDF Exportor.
    JRPdfExporter exporter = new JRPdfExporter();

    ExporterInput exporterInput = new SimpleExporterInput(print);
    // ExporterInput
    exporter.setExporterInput(exporterInput);

    // ExporterOutput
    OutputStreamExporterOutput exporterOutput = new SimpleOutputStreamExporterOutput(
            "C:/jasperoutput/FirstJasperReport.pdf");
    // Output
    exporter.setExporterOutput(exporterOutput);

    //
    SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
    exporter.setConfiguration(configuration);
    exporter.exportReport();

    System.out.print("Done2!");
}
}

Can anyone tell me what can I do to solve this?


Answer:

please try putting jdt-compiler.jar in you classpath.let me know if you have problem doing that