pentaho / pentaho-reporting

Java class library for generating reports.
GNU Lesser General Public License v2.1
276 stars 359 forks source link

There are no chart images #1652

Open khauser opened 1 month ago

khauser commented 1 month ago

Hi there,

we try to use the pentaho reporting SDK within a spring boot application.

build.gradle:

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.2.5'
    id 'io.spring.dependency-management' version '1.1.4'
}
...
java {
    sourceCompatibility = '21'
}

repositories {
    mavenCentral()
    maven { url 'https://repo.orl.eng.hitachivantara.com/artifactory/pnt-mvn/'  }
}

ext {
    pentahoReportingVersion = '9.4.0.0-343'
    postgresqlVersion = '42.7.1'
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-freemarker'
    implementation 'org.springframework.boot:spring-boot-starter-jdbc'

    runtimeOnly group: 'org.postgresql', name: 'postgresql', version: "${postgresqlVersion}"

    implementation group: 'org.pentaho.reporting.engine', name: 'classic-core', version: "${pentahoReportingVersion}"
    implementation group: 'org.pentaho.reporting.engine', name: 'classic-extensions', version: "${pentahoReportingVersion}"
    implementation group: 'org.pentaho.reporting.engine', name: 'legacy-charts', version: "${pentahoReportingVersion}"

    implementation group: 'org.jfree', name: 'jfreechart', version: '1.0.19'
...

ReportingService.java:

        ClassicEngineBoot.getInstance().start();

        final ResourceManager resourceManager = new ResourceManager();
        resourceManager.registerDefaults();

        final var baos = new ByteArrayOutputStream();

        try
        {
            Resource res = resourceManager.createDirectly(
                            resourceLoader.getResource(REPORTING_FILE_PATH).getURI().toURL(), MasterReport.class);
            final MasterReport masterReport = (MasterReport)res.getResource();
            queryParams = Map.ofEntries(....);

            addParametersToReport(masterReport, queryParams);

            HtmlReportUtil.createStreamHTML(masterReport, baos);

With this our report is generated but there are no chart images shown. What could be the problem here? In the report designer the charts show up.

Thanks for help! Karsten

khauser commented 1 month ago

If I use HtmlReportUtil.createDirectoryHTML the images are there. Now I should be able to create a workaround.