PDA

View Full Version : Problem generating my first report



felix.schmidt
08-22-2013, 09:44 AM
Hi,

i try to generate a report from Java, but i only receive a blank page right now.

Any help would be appreciated.

my code is from the Pentaho for Java Developers Book:



String load = Table.class.getResource("log.properties")
.getFile();
PropertyConfigurator.configure(load);
LOGGER.getParent().setLevel(Level.WARN);

ClassicEngineBoot.getInstance().start();


MasterReport report = new MasterReport();


DefaultTableModel t = new DefaultTableModel(new Object[][] {
{ "Hallo", 1 }, { "Welt", 2 } }, new String[] { "Text",
"Zeichen" });



final TableDataFactory dataFactory = new TableDataFactory();
dataFactory.addTable("default", t);
report.setDataFactory(dataFactory);


FormulaExpression form = new FormulaExpression();
form.setName("simple");
form.setFormula("=[Zeichen]+100");
report.addExpression(form);


ReportHeader rH = new ReportHeader();
ReportFooter rF = new ReportFooter();


report.setReportHeader(rH);
report.setReportFooter(rF);


ItemBand band = new ItemBand();
report.setItemBand(band);


LabelElementFactory labelFactory = new LabelElementFactory();
labelFactory.setText("LaberText");
labelFactory.setX(1f);
labelFactory.setY(1f);
labelFactory.setMaximumWidth(100f);
labelFactory.setMaximumHeight(20f);
labelFactory.setBold(true);


Element label = labelFactory.createElement();
rH.addElement(label);


TextFieldElementFactory textFactory = new TextFieldElementFactory();
textFactory.setFieldname("Text");
textFactory.setX(1f);
textFactory.setY(1f);
textFactory.setMaximumHeight(20f);
textFactory.setMaximumWidth(100f);
Element textField = textFactory.createElement();
band.addElement(textField);


NumberFieldElementFactory numberFactory = new NumberFieldElementFactory();
numberFactory.setFieldname("simple");
numberFactory.setX(101f);
numberFactory.setY(1f);
numberFactory.setMaximumHeight(20f);
numberFactory.setMaximumWidth(100f);
Element zahlField = numberFactory.createElement();
band.addElement(zahlField);


// Save Pdf to harddisc
FileOutputStream out = new FileOutputStream(new File("report2.pdf"));
PdfReportUtil.createPDF(report, out);
out.close();
out.flush();



I get the following warning when i run this code:



08/22/2013 15:29:15.359 WARN [main] org.pentaho.reporting.libraries.base.boot.PackageState - Unable to initialize the module misc-bsf
08/22/2013 15:29:15.391 WARN [main] org.pentaho.reporting.libraries.base.boot.PackageState - Unable to initialize the module ext-sbarcodes
08/22/2013 15:29:15.435 WARN [main] org.pentaho.reporting.libraries.base.boot.PackageState - Unable to initialize the module output-table-xls
08/22/2013 15:29:15.451 WARN [main] org.pentaho.reporting.libraries.base.boot.PackageManager - Required dependency 'org.pentaho.reporting.engine.classic.core.modules.output.table.xls.ExcelTableModule' for module 'org.pentaho.reporting.engine.classic.core.modules.gui.xls.ExcelExportGUIModule not initializable.
08/22/2013 15:29:15.906 WARN [main] org.pentaho.reporting.engine.classic.core.layout.process.InfiniteMinorAxisLayoutStep - Auto-Corrected zero-width first-line on paragraph
08/22/2013 15:29:15.907 WARN [main] org.pentaho.reporting.engine.classic.core.layout.process.RevalidateAllAxisLayoutStep - Revalidate: Auto-Corrected zero-width linebox.
08/22/2013 15:29:15.910 WARN [main] org.pentaho.reporting.engine.classic.core.layout.process.InfiniteMinorAxisLayoutStep - Auto-Corrected zero-width first-line on paragraph
08/22/2013 15:29:15.910 WARN [main] org.pentaho.reporting.engine.classic.core.layout.process.InfiniteMinorAxisLayoutStep - Auto-Corrected zero-width first-line on paragraph
08/22/2013 15:29:15.910 WARN [main] org.pentaho.reporting.engine.classic.core.layout.process.RevalidateAllAxisLayoutStep - Revalidate: Auto-Corrected zero-width linebox.
08/22/2013 15:29:15.910 WARN [main] org.pentaho.reporting.engine.classic.core.layout.process.RevalidateAllAxisLayoutStep - Revalidate: Auto-Corrected zero-width linebox.
08/22/2013 15:29:15.911 WARN [main] org.pentaho.reporting.engine.classic.core.layout.process.InfiniteMinorAxisLayoutStep - Auto-Corrected zero-width first-line on paragraph
08/22/2013 15:29:15.911 WARN [main] org.pentaho.reporting.engine.classic.core.layout.process.InfiniteMinorAxisLayoutStep - Auto-Corrected zero-width first-line on paragraph
08/22/2013 15:29:15.911 WARN [main] org.pentaho.reporting.engine.classic.core.layout.process.RevalidateAllAxisLayoutStep - Revalidate: Auto-Corrected zero-width linebox.
08/22/2013 15:29:15.912 WARN [main] org.pentaho.reporting.engine.classic.core.layout.process.RevalidateAllAxisLayoutStep - Revalidate: Auto-Corrected zero-width linebox.
08/22/2013 15:29:15.917 WARN [main] org.pentaho.reporting.engine.classic.core.layout.process.InfiniteMinorAxisLayoutStep - Auto-Corrected zero-width first-line on paragraph
08/22/2013 15:29:15.917 WARN [main] org.pentaho.reporting.engine.classic.core.layout.process.RevalidateAllAxisLayoutStep - Revalidate: Auto-Corrected zero-width linebox.
08/22/2013 15:29:15.918 WARN [main] org.pentaho.reporting.engine.classic.core.layout.process.InfiniteMinorAxisLayoutStep - Auto-Corrected zero-width first-line on paragraph
08/22/2013 15:29:15.918 WARN [main] org.pentaho.reporting.engine.classic.core.layout.process.InfiniteMinorAxisLayoutStep - Auto-Corrected zero-width first-line on paragraph
08/22/2013 15:29:15.918 WARN [main] org.pentaho.reporting.engine.classic.core.layout.process.RevalidateAllAxisLayoutStep - Revalidate: Auto-Corrected zero-width linebox.
08/22/2013 15:29:15.918 WARN [main] org.pentaho.reporting.engine.classic.core.layout.process.RevalidateAllAxisLayoutStep - Revalidate: Auto-Corrected zero-width linebox.
08/22/2013 15:29:15.919 WARN [main] org.pentaho.reporting.engine.classic.core.layout.process.InfiniteMinorAxisLayoutStep - Auto-Corrected zero-width first-line on paragraph
08/22/2013 15:29:15.919 WARN [main] org.pentaho.reporting.engine.classic.core.layout.process.InfiniteMinorAxisLayoutStep - Auto-Corrected zero-width first-line on paragraph
08/22/2013 15:29:15.919 WARN [main] org.pentaho.reporting.engine.classic.core.layout.process.RevalidateAllAxisLayoutStep - Revalidate: Auto-Corrected zero-width linebox.
08/22/2013 15:29:15.919 WARN [main] org.pentaho.reporting.engine.classic.core.layout.process.RevalidateAllAxisLayoutStep - Revalidate: Auto-Corrected zero-width linebox.





I think that this may be because there are some missing jars, so this is from my pom.xml:




<repository>
<name>pentaho</name>
<id>pentaho-reporting-engine</id>
<url>http://repository.pentaho.org/artifactory/pentaho/</url>
</repository>


<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.beanshell</groupId>
<artifactId>bsh</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.bsf</groupId>
<artifactId>bsf-api</artifactId>
<version>3.1</version>
</dependency>


<dependency>
<groupId>pentaho-reporting-engine</groupId>
<artifactId>pentaho-reporting-engine-classic-core</artifactId>
<version>3.9.1-GA</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>pentaho-reporting-engine</groupId>
<artifactId>pentaho-reporting-engine-classic-extensions</artifactId>
<version>3.9.1-GA</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libbase</artifactId>
<version>1.2.8</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libdocbundle</artifactId>
<version>1.2.8</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libfonts</artifactId>
<version>1.2.8</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libformat</artifactId>
<version>1.2.8</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libformula</artifactId>
<version>1.2.8</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libloader</artifactId>
<version>1.2.8</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>librepository</artifactId>
<version>1.2.8</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libserializer</artifactId>
<version>1.2.8</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libxml</artifactId>
<version>1.2.8</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libswing</artifactId>
<version>1.2.8</version>
</dependency>

<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libsparkline</artifactId>
<version>1.2.9</version>
</dependency>



<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext-rtf</artifactId>
<version>2.1.7</version>
</dependency>

felix.schmidt
08-27-2013, 08:30 AM
UPDATE:

I tried to simplify the problem by creating a new project without maven and imported all jars which i could find in the report designer.

again, i just receive a empty report.

then i simplefied the code until there is only a lable with "Hello World".

still just an empty report.

my code now looks like this:




ClassicEngineBoot.getInstance().start();


MasterReport report = new MasterReport();


ReportHeader rH = new ReportHeader();
report.setReportHeader(rH);


LabelElementFactory labelFactory = new LabelElementFactory();
labelFactory.setText("Hello World");
labelFactory.setX(1f);
labelFactory.setY(1f);
labelFactory.setMaximumWidth(100f);
labelFactory.setMaximumHeight(20f);
labelFactory.setBold(true);


Element label = labelFactory.createElement();
rH.addElement(label);


// Save Pdf to harddisc
FileOutputStream out = new FileOutputStream(new File("report.pdf"));
PdfReportUtil.createPDF(report, out);
out.close();
out.flush();



any help would be appreciated