0

Below is my student.json file.

[
    {
        "studentName": "NIDHI AGARWAL",
        "USN": "1BM18CV149",
        "Semester": "II SEM",
        "Branch": "Civil Engineering",
        "subjectDetails": [{
                "SLNo": 1,
                "subjectCode": "18MBA1PCAC",
                "subjectName": "Physics",
                "Eligibility": "Not Eligible"
            },
            {
                "SLNo": 2,
                "subjectCode": "18MBA1PCAC",
                "subjectName": "Biology",
                "Eligibility": "Eligible"
            }
        ]
    },
    {
        "studentName": "Kiran",
        "USN": "1BM18CV149",
        "Semester": "II SEM",
        "Branch": "Civil Engineering",
        "subjectDetails": [{
                "SLNo": 1,
                "subjectCode": "18MBA1PCAD",
                "subjectName": "Maths",
                "Eligibility": "Not Eligible"
            },
            {
                "SLNo": 2,
                "subjectCode": "18MBA1PCAC",
                "subjectName": "Science",
                "Eligibility": "Eligible"
            }
        ]
    },
    {
        "studentName": "Praveen",
        "USN": "1BM18CV149",
        "Semester": "II SEM",
        "Branch": "Civil Engineering",
        "subjectDetails": [{
                "SLNo": 1,
                "subjectCode": "18MBA1PCAD",
                "subjectName": "English",
                "Eligibility": "Not Eligible"
            },
            {
                "SLNo": 2,
                "subjectCode": "18MBA1PCAC",
                "subjectName": "Kannada",
                "Eligibility": "Eligible"
            }
        ]
    },
    {
        "studentName": "Ashwin",
        "USN": "1BM18CV149",
        "Semester": "II SEM",
        "Branch": "Civil Engineering",
        "subjectDetails": [{
                "SLNo": 1,
                "subjectCode": "18MBA1PCAD",
                "subjectName": "EC",
                "Eligibility": "Not Eligible"
            },
            {
                "SLNo": 2,
                "subjectCode": "18MBA1PCAC",
                "subjectName": "KAS",
                "Eligibility": "Eligible"
            }
        ]
    },
    {
        "studentName": "Amit",
        "USN": "1BM18CV149",
        "Semester": "II SEM",
        "Branch": "Civil Engineering",
        "subjectDetails": [{
                "SLNo": 1,
                "subjectCode": "18MBA1PCAD",
                "subjectName": "CS",
                "Eligibility": "Not Eligible"
            },
            {
                "SLNo": 2,
                "subjectCode": "18MBA1PCAC",
                "subjectName": "IS",
                "Eligibility": "Eligible"
            }
        ]
    }
]

Below is my jrxml file.

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.13.0.final using JasperReports Library version 6.13.0-46ada4d1be8f3c5985fd0b6146f3ed44caed6f05  -->
<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="BMSCE_HALLTICKET" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isIgnorePagination="true" uuid="c51566f5-ab95-4707-b371-2ef8762b72f4">
    <property name="net.sf.jasperreports.json.source" value="student.json"/>
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="DataAdapter.xml"/>
    <style name="Table_CH" mode="Opaque" 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_TD" mode="Opaque" 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="StudentDetailsDataSet" uuid="6de18a40-c6a3-4367-9574-7e6bd10d9d70">
        <property name="net.sf.jasperreports.json.source" value="student.json"/>
        <queryString>
            <![CDATA[]]>
        </queryString>
        <field name="subjectCode" class="java.lang.String"/>
        <field name="subjectName" class="java.lang.String"/>
        <field name="Eligibility" class="java.lang.String"/>
        <field name="SLNo" class="java.lang.Integer"/>
    </subDataset>
    <parameter name="JSONBeanParam" class="net.sf.jasperreports.engine.json.JRJsonNode"/>
    <parameter name="CollectionBeanParam" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <field name="studentName" class="java.lang.String"/>
    <field name="USN" class="java.lang.String"/>
    <field name="Semester" class="java.lang.String"/>
    <field name="Branch" class="java.lang.String"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <detail>
        <band height="316" splitType="Stretch">
            <rectangle>
                <reportElement mode="Transparent" x="80" y="0" width="720" height="316" uuid="89d405b7-d585-4b96-977c-15fcd0003fad"/>
            </rectangle>
            <componentElement>
                <reportElement x="125" y="110" width="630" height="170" uuid="5c165218-9085-4a3b-8a0e-1aab0a7469ea">
                    <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
                    <property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/>
                    <property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/>
                    <property name="com.jaspersoft.studio.components.autoresize.proportional" value="true"/>
                </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="StudentDetailsDataSet" uuid="2009acfc-3137-4017-a9dd-e0b263a634a9">
                        <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource() ]]></dataSourceExpression>
                    </datasetRun>
                    <jr:column width="83" uuid="f21ea19e-71d0-4a94-8bcb-3d1c4af367da">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/>
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement x="0" y="0" width="83" height="30" uuid="ab1e7c7e-ce73-4d22-8bcb-6fd1c695838c"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                <text><![CDATA[Sl No.]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement x="0" y="0" width="83" height="30" uuid="d33f5be3-9c69-4a50-8979-1b290b283767">
                                    <property name="net.sf.jasperreports.export.json.path" value="slno"/>
                                </reportElement>
                                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                <textFieldExpression><![CDATA[$F{SLNo}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="90" uuid="a41271c6-5397-4190-a489-557874bd3b9d">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/>
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement x="0" y="0" width="90" height="30" uuid="0beed8cd-8d3b-49aa-bdef-be8c7726682e"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                <text><![CDATA[Course Code]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="30" uuid="b4605e22-9fc5-45a8-8dab-079a9268f509"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                <textFieldExpression><![CDATA[$F{subjectCode}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="220" uuid="450d9dc0-0fbe-4033-a243-8f5e0e6f5248">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column3"/>
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement x="0" y="0" width="220" height="30" uuid="ecc270f7-b02a-437a-8f88-084a7e827d8f"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                <text><![CDATA[Course Title]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement x="0" y="0" width="220" height="30" uuid="fcb61603-14d9-4684-b6b6-c61e9c79d769"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                <textFieldExpression><![CDATA[$F{subjectName}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="119" uuid="e8cd6ba8-1e22-4eeb-b1ea-2b943ea453cb">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column4"/>
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement x="0" y="0" width="119" height="30" uuid="480d501c-49f2-4ec2-b09d-eb626adf77ea"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                <text><![CDATA[Eligibility]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement x="0" y="0" width="119" height="30" uuid="a4720b12-6b47-4b89-9ed9-a97c5f35f77d"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                <textFieldExpression><![CDATA[$F{Eligibility}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="118" uuid="f2b73c8f-5d07-47ee-8a2e-40a54d95bcf2">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column5"/>
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement x="0" y="0" width="118" height="30" uuid="9a3565a7-5c04-46f4-8dc8-cd4a4bee55b7"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                <text><![CDATA[Invigilator Signature]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="Table_TD" height="30"/>
                    </jr:column>
                </jr:table>
            </componentElement>
            <textField>
                <reportElement x="200" y="10" width="200" height="22" uuid="a48bc6bd-4a75-49a1-ae38-b53640a577e9"/>
                <textFieldExpression><![CDATA[$F{studentName}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="200" y="30" width="200" height="22" uuid="0eeecefa-ccbf-4782-bd7d-8d2d67068925"/>
                <textFieldExpression><![CDATA[$F{USN}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="200" y="52" width="200" height="22" uuid="fb5b8e76-3549-47c1-aeb0-e03c0c3fef8d"/>
                <textFieldExpression><![CDATA[$F{Semester}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="200" y="73" width="200" height="22" uuid="deb82ac6-a242-4a71-b583-321b35757c5d"/>
                <textFieldExpression><![CDATA[$F{Branch}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="125" y="10" width="75" height="20" uuid="0d030822-a92b-4003-b4f0-052920dc30ab"/>
                <text><![CDATA[Name : ]]></text>
            </staticText>
            <staticText>
                <reportElement x="125" y="31" width="75" height="20" uuid="fbaf6968-5674-487e-88bc-0cf93679b7e2"/>
                <text><![CDATA[USN : ]]></text>
            </staticText>
            <staticText>
                <reportElement x="125" y="51" width="75" height="23" uuid="de2b5d4f-6086-48da-bbf5-c1fed18a96b1"/>
                <text><![CDATA[Semester : ]]></text>
            </staticText>
            <staticText>
                <reportElement x="125" y="74" width="75" height="20" uuid="5ded0c4f-fb7d-413e-a7b0-61b389001c67"/>
                <text><![CDATA[Branch : ]]></text>
            </staticText>
        </band>
    </detail>
</jasperReport>

Below is my Java code to generate Japer reports.

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.json.simple.*;
import org.json.simple.parser.*;

import net.sf.jasperreports.engine.JRAbstractExporter;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JREmptyDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.export.SimpleExporterInput;
import net.sf.jasperreports.export.SimpleOutputStreamExporterOutput;
import net.sf.jasperreports.export.SimplePdfExporterConfiguration;
import net.sf.jasperreports.view.JasperViewer;

public class BMSCE_HALLTICKET {

    /**
     * @param args
     * @throws JRException
     * @throws IOException
     * @throws ParseException
     */
    public static void main(String args[]) throws JRException, IOException, ParseException {

        /* Output file location to create report in pdf form */
        JSONParser parser = new JSONParser();
        List<JasperPrint> jasperPrints = new ArrayList<JasperPrint>();
        List<Student> listItems=null;
        JSONArray array = (JSONArray) parser.parse(new FileReader("C:\\Users\\Sony\\Desktop\\student.json"));
        for (int i = 0; i < array.size(); i++) {
            listItems=new ArrayList<Student>();
            Student std = new Student();
            JSONObject obj = (JSONObject) array.get(i);
            std.setUSN((String) obj.get("USN"));
            std.setStudentName((String) obj.get("studentName"));
            std.setSemester((String) obj.get("Semester"));
            std.setBranch((String) obj.get("Branch"));
            JSONArray subjectsDetails = (JSONArray) obj.get("subjectDetails");
            List<subjectDetails> subdetails = new ArrayList<>();
            for (int j = 0; j < subjectsDetails.size(); j++) {
                subjectDetails sd = new subjectDetails();
                JSONObject object = (JSONObject) subjectsDetails.get(j);
                if (object != null) {
                    sd.setSlno(((Long) object.get("SLNo")).intValue());
                    sd.setSubjectCode((String) object.get("subjectCode"));
                    sd.setSubjectName((String) object.get("subjectName"));
                    sd.setIsEligible((String) object.get("Eligibility"));
                    subdetails.add(sd);
                }
            }
            std.setSubDetails(subdetails);
            listItems.add(std);
            JRBeanCollectionDataSource itemsJRBean1 = new JRBeanCollectionDataSource(listItems);
            Map<String, Object> parameters1 = new HashMap<String, Object>();
            parameters1.put("CollectionBeanParam", itemsJRBean1);
            InputStream input1 = new FileInputStream(
                    new File("C:\\Users\\Sony\\JaspersoftWorkspace\\MyReports\\BMSCE_HALLTICKET.jrxml"));
            JasperDesign jasperDesign1 = JRXmlLoader.load(input1);
            JasperReport jasperReport1 = JasperCompileManager.compileReport(jasperDesign1);
            JasperPrint jasperPrint1 = JasperFillManager.fillReport(jasperReport1, parameters1, new JREmptyDataSource());
            jasperPrints.add(jasperPrint1);
        }


        JRPdfExporter exporter = new JRPdfExporter();
        exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrints)); // Set as export input my list with
        // JasperPrint s
        exporter.setExporterOutput(new SimpleOutputStreamExporterOutput("output23.pdf")); // or any other out streaam
        SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
        configuration.setCreatingBatchModeBookmarks(true); // add this so your bookmarks work, you may set other
        // parameters
        exporter.setConfiguration(configuration);
        exporter.exportReport();

        System.out.println("File Generated");
    }

}

I'm trying to generate jasper reports but only the skeleton is getting displayed but the data is null please help.

Alex K
  • 22,315
  • 19
  • 108
  • 236

1 Answers1

0

JasperReports has built-in support for JSON data, so you don't need to parse the JSON file and construct the JRBeanCollectionDataSource that you don't use anyway.

You need to fix your report template first:

  1. Add the proper language to your queryString: json or jsonql

     <queryString language="json">
         <![CDATA[]]>
     </queryString>
    

    and you'll immediately see the textFields above the table being populated when previewing the report. If there, try to pick the 'Don't use a Data Adapter' option from the Data Adapter drop down.

  2. Use a proper dataSource expression for your table component, instead of empty dataSource

     <datasetRun subDataset="StudentDetailsDataSet" uuid="2009acfc-3137-4017-a9dd-e0b263a634a9">
         <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("subjectDetails")]]></dataSourceExpression>
     </datasetRun>
    

    This should fix the table component.

Your java code should now look simpler:

public static void main(String args[]) throws Exception {
    JasperDesign jasperDesign = JRXmlLoader.load(new File("C:\\Users\\Sony\\JaspersoftWorkspace\\MyReports\\BMSCE_HALLTICKET.jrxml"));

    JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
    // uncomment the next line if your JSON file is on a different path than the one set inside JRXML
    //jasperReport.setProperty(JsonQueryExecuterFactory.JSON_SOURCE, "path/to/student.json");

    JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null);

    JasperExportManager.exportReportToPdfFile(jasperPrint, "output23.pdf");

    System.out.println("File Generated");
}

EDIT: tested the code with JasperReports version 6.3.0 and 6.13.0

The output: jr_6.3.0_output

Narcis
  • 2,421
  • 4
  • 16
  • 23
  • Thanks @Narcis it is working in jasper studio but the java code you suggested is not working i'm unable to populate the pdf please help. – Kiran Kumar D M Sep 18 '20 at 13:48
  • Did you encounter any errors while running the code? I have tested it before posting – Narcis Sep 18 '20 at 14:29
  • I'm getting warning like "The supplied java.sql.Connection object is null" and the output pdf is empty @Narcis – Kiran Kumar D M Sep 18 '20 at 14:37
  • What version of JasperReports are you using to run the code? – Narcis Sep 18 '20 at 14:58
  • Jasper Reports 6.3.0 version.I think the error might be because we are passing null to fillreport method. – Kiran Kumar D M Sep 18 '20 at 15:03
  • That `null` is for report parameters map. The datasource is built internally based on the `json` language set for `queryString` and the `net.sf.jasperreports.json.source` property. Please make sure you are using the same exact files that you have supplied here. Double check the paths and change the exported pdf file name/path. – Narcis Sep 18 '20 at 15:29
  • I'm using same files which i have supplied and i have changed exported pdf file name but still it is empty.By the way which version are you using?Are you able to generate pdf and is it showing values correctly ? @Narcis – Kiran Kumar D M Sep 18 '20 at 15:30
  • I've edited my answer with proof from JR 6.3.0. Try setting the absolute path for the JSON file, either inside the JRXML or by uncommenting the `jasperReport.setProperty(...)` line – Narcis Sep 18 '20 at 15:43
  • I have set the absolute path have a look here jasperReport.setProperty(JsonQueryExecuterFactory.JSON_SOURCE, "C:\\Users\\Sony\\Desktop\\student.json"); but still it doesn't work . – Kiran Kumar D M Sep 18 '20 at 15:51
  • I changed it to 6.13.0 version now i'm getting this error.java.lang.NoClassDefFoundError -> Caused by: java.lang.ClassNotFoundException – Kiran Kumar D M Sep 18 '20 at 16:09
  • Do you have a maven-based project? How do you keep track of all dependencies to run your code? – Narcis Sep 18 '20 at 16:22
  • Yes i do have maven based project .There is a folder called Referenced Libraries where i manage all the jars. – Kiran Kumar D M Sep 18 '20 at 16:35
  • I suggest you create a separate maven project just with the JasperReports library as dependency and these files and Java code in order to isolate the issue. – Narcis Sep 18 '20 at 18:48
  • I have created a new project .I'm getting this error Exception in thread "main" java.lang.NullPointerException at net.sf.jasperreports.engine.design.JRAbstractCompiler.deleteSourceFiles(JRAbstractCompiler.java:407) at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:281) at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:358) at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:618) at com.test.BMSHallTicketDownload.main(BMSHallTicketDownload.java:47) – Kiran Kumar D M Sep 19 '20 at 05:21
  • could you please send me your project setup to my mail id kirankumardm141@gmail.com ? @Narcis – Kiran Kumar D M Sep 19 '20 at 05:31
  • Or atleast can you upload it on github so that i will clone and import that maven project @Narcis – Kiran Kumar D M Sep 19 '20 at 07:37
  • It worked thanks @Narcis but i have one question why i'm getting nullpointerexception at this line in the above code which you have shared-> JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); Is the jasper design object null ? – Kiran Kumar D M Sep 19 '20 at 12:14
  • If you can help me with this that would be really helpful https://stackoverflow.com/questions/63968851/im-unable-to-generate-jasper-report-pdf-using-java-im-stuck-with-this-error-at – Kiran Kumar D M Sep 19 '20 at 12:36
  • 1
    Please stop opening similar issues. There's no point in opening similar bugs while all the info is still here. You won't get any more attention. – Narcis Sep 19 '20 at 13:47
  • Ok sorry @Narcis I will close those issue I'mnew to Jasper reports so i'maskng questions and i have one question why i'm getting nullpointerexception at this line in the above code which you have shared-> JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); Is the jasper design object null ? – Kiran Kumar D M Sep 19 '20 at 14:24
  • 1
    The NPE is not at that line. From the stacktrace that you posted it looks internal to the JR library. The issue seems specific to the 6.13 version as suggested [here](https://stackoverflow.com/a/63072294/5882963) but in combination with Adopt OpenJDK. Is it the same for you? – Narcis Sep 19 '20 at 15:40
  • I used jasper reports 6.11.0 version and now it is working.I want to generate two jasper reports in one single page and all reports populated in one single pdf i.e in my case there are five json objects so two per page means three pages in one single pdf can we do that? @Narcis – Kiran Kumar D M Sep 20 '20 at 04:46
  • 1
    That is a matter of customizing the report template(the JRXML). You probably need to resize the detail band or something, but that is another issue for which there is plenty of guidance out there. Please close this one. – Narcis Sep 20 '20 at 09:51