Print detail list content in a new page in Jasper Report

I have a jasper report that has main report and detail report as a list, the data is being sent from server side Java as a java bean that has some attributes including a list of another Java bean, this list is used to fill the detail list, the problem is that, the client need that each detail record should be in a separate page

I already try to use Break at end of the list layout, but when I try to generate the report I got the error:

Caused by: java.lang.NullPointerException
    at net.sf.jasperreports.engine.fill.JRFillBreak.prepare(
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(
    at net.sf.jasperreports.components.list.FillListContents.prepare(
    at net.sf.jasperreports.components.list.VerticalFillList.fillContents(
    at net.sf.jasperreports.components.list.VerticalFillList.prepare(
    at net.sf.jasperreports.engine.fill.JRFillComponentElement.prepare(
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(
    at net.sf.jasperreports.engine.fill.JRFillBand.fill(
    at net.sf.jasperreports.engine.fill.JRFillBand.fill(
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(
    at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(
    at net.sf.jasperreports.engine.fill.JRFiller.fill(
    at net.sf.jasperreports.engine.JasperFillManager.fill(
    at net.sf.jasperreports.engine.JasperFillManager.fillReport(

Here's the java code for generating the report:

due to sensitive client information I couldn't provide the exact code but the same structure

Report Bean

public class ReportBean implements Serializable {    // Main attributes used in the Main report Header and Footer
    private String attr1;
    private String attr2;
    private List<DetailBean> list;    // setters and getters

Detail Bean

public class DetailBean implements Serializable {    // Detail attributes used in the list details to show detail records
    private String attr1;
    private String attr2;
    // setters and getters

Generating Report

// createReport() function retrieve data from data base, fill the main report information and the detail report list
ReportBean report = createReport();
String filename = "";
byte[] result = null;
try (InputStream is = new FileInputStream(filename)) {
    result = JasperReportsGenerator.createPDF(is, Collections.singletonList(report), params);
catch (IOException e) {}

And here's the report structure:
Main Report

List details

Report structure

Thanks in advance

michael.samir.g's picture
Joined: May 24 2019 - 6:19am
Last seen: 3 years 4 months ago

1 Answer:

Don't use list experience says, that un most cases you will come to rhe limitations of list element and you will refactor it to subreport. So just change to subreport and place the break element into the detail section of the subreport, so that each record will do an break.

You could then also use groups and also the group feature StartOnNewPage

Hth + regards


C-Box's picture
Joined: Jul 19 2006 - 5:58pm
Last seen: 6 months 6 days ago