Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: Problem generating my first report

  1. #1

    Default Problem generating my first report

    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:
    Code:
            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:

    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:

    Code:
            <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>

  2. #2

    Default

    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:

    Code:
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.