Jump to content

Recommended Posts

Posted

Hello, guys

I created four jasper files on Jaspersoft Studio (5.6) with four subreports containing the following expression:

new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource ($F{unidadesFilhasTO})

The code below is throwing an OutOfMemoryException after 10 minutes, It seems that occur a infinite loop.
But when I try to generate the PDF without the last jasper file it works. The jasper files are identical.

I tried to remove the subreport in the last jasper file, but it not works.
I tried to use the same jasper files too, but occured the same error.

How can I solve this?

 

try {     UTO uTO1 = new UTO();  uTO1.setNome("1");    UTO uTO2 = new UTO();  uTO2.setNome("2");    UTO uTO3 = new UTO();  uTO3.setNome("3");    UTO uTO4 = new UTO();  uTO4.setNome("4");    uTO1.setUnidadesFilhasTO(Arrays.asList(uTO2));  uTO2.setUnidadesFilhasTO(Arrays.asList(uTO3));  uTO3.setUnidadesFilhasTO(Arrays.asList(uTO4));    JRDataSource jrd = new JRBeanCollectionDataSource(Arrays.asList(uTO1));    byte[] bytes = JasperRunManager.runReportToPdf(new FileInputStream(new File("C:\SISGEC\Reports\Jasper\RelatorioUnidades\UnidadeReport.jasper")), new HashMap<String, Object>(), jrd);    FileOutputStream out = new FileOutputStream(new File("C:\SISGEC\Reports\PDF\gustavo.antunes\Teste.pdf"));  out.write(bytes);  out.flush();  out.close();  System.out.println("Foi");   } catch (Exception e) {  // TODO Auto-generated catch block  e.printStackTrace(); }[/code]

 

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted

I don't think anybody would have any idea of what you're trying to do by looking at your codes because it doesn't seem to have any subreports in them.

This is also mentioned several times in this forum but "does not work" doesn't make any sense to anybody else beside you. You have to attach the exact error message.

As such, the only advice I can give is to run each subreport to make sure they work before calling them from the main report.

Posted

Thanks by your advice, hozawa.

I executed that code now and it's not returning any error. but the program never stops (it's executing during 20min). 

The name of the jasper files are listed below:

Name of the first jasper file: UnidadeReport.jasper
Name of the second jasper file: UnidadeReport2.jasper
Name of the third jasper file: UnidadeReport3.jasper
Name of the fourth jasper file: UnidadeReport4.jasper

The datasource expression of each subreport are the fields below:

Subreport in the first jasper file: uTO1.getUnidadesFilhasTO()
Subreport in the second jasper file: uTO2.getUnidadesFilhasTO()
Subreport in the third jasper file: uTO3.getUnidadesFilhasTO()

Example of the first subreport:

<subreport>
      <reportElement x="0" y="136" width="554" height="40" uuid="03199f9e-2af8-44fb-bb56-48e8475c70cf">
            <printWhenExpression><![CDATA[$F{unidadesFilhasTO} != null]]></printWhenExpression>
      </reportElement>
      <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource ($F{unidadesFilhasTO})]]>                           </dataSourceExpression>
        <subreportExpression><![CDATA["C:/SISGEC/Reports/Jasper/RelatorioUnidades/UnidadeReport2.jasper"]]></subreportExpression>
</subreport>

There's no information in the jasper files, only the subreports and the field "unidadesFilhasTO". It seems that when the jaspersoft studio has more than 3 nested reports, is starting an infinite loop. I don't know why it's occurring.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...