Report xlsx to pdf: no ImagePreloader found

Locally on Windows there is no problem but with Deployment on linux (dokku).
Libreoffice is installed. The template format is xlsx with inlining images.
The images are loaded to band as byte array, added value format ${bitmap:WxH}.

First converting xlsx to pdf there was a problem with “imconvert”:

RestControllerExceptionHandler: Error checking image format
Cannot run program “imconvert”: error=2, No such file or directory

After installing ImageMagick on Docker and add sym link for convert - imconvert, i get another error: no ImagePreloader found (converting the .img to .png / .bmp directly at Docker was no problem).
Is there a solution or can you give me some advice, thank you in advance.

2020-05-06T12:41:21.685038700Z app[web.1]: Error checking image format
2020-05-06T12:41:21.685041917Z app[web.1]: The file format is not supported. No ImagePreloader found for file:/tmp/img9018058703129664189.img
2020-05-06T12:41:21.685044791Z app[web.1]: com.haulmont.reports.exception.ReportingException: An error occurred while inserting bitmap to xlsx file Report name [QuoteSheet]
2020-05-06T12:41:21.685047701Z app[web.1]: Error checking image format
2020-05-06T12:41:21.685050622Z app[web.1]: The file format is not supported. No ImagePreloader found for file:/tmp/img9018058703129664189.img
2020-05-06T12:41:21.685053269Z app[web.1]:      at com.haulmont.reports.ReportingBean.createReportDocument(ReportingBean.java:361) ~[na:na]
2020-05-06T12:41:21.685056368Z app[web.1]:      at com.haulmont.reports.ReportingBean.createReportDocument(ReportingBean.java:304) ~[na:na]
2020-05-06T12:41:21.685059125Z app[web.1]:      at com.haulmont.reports.ReportingBean.createReport(ReportingBean.java:198) ~[na:na]

# grep -i preloader stacktrace.log
2020-05-06T12:41:21.663017427Z app[web.1]: Caused by: org.apache.xmlgraphics.image.loader.ImageException: The file format is not supported. No ImagePreloader found for file:/tmp/img9018058703129664189.img
2020-05-06T12:41:21.675629101Z app[web.1]: The file format is not supported. No ImagePreloader found for file:/tmp/img9018058703129664189.img

Hi,

I have the same problem. I have a report with docx template that put output into pdf file. The image field has a formatter:

${imageFileId:200x200}

In Windows and Mac all works well. The problem occurs in docker container load on CentosOS. The others report without image run correctly.

This is my stack strace:

stacktrace.txt (53.6 KB)

Thanks to all for helping

I did a step forward: the problem is related to file org.apache.xmlgraphics.image.loader.spi.ImagePreloader in uber jar under LIB-INF/shared/META-INF/services. Normaly this file should content this lines:

org.apache.xmlgraphics.image.loader.impl.PreloaderTIFF
org.apache.xmlgraphics.image.loader.impl.PreloaderGIF
org.apache.xmlgraphics.image.loader.impl.PreloaderJPEG
org.apache.xmlgraphics.image.loader.impl.PreloaderBMP
org.apache.xmlgraphics.image.loader.impl.PreloaderEMF
org.apache.xmlgraphics.image.loader.impl.PreloaderEPS
org.apache.xmlgraphics.image.loader.impl.imageio.PreloaderImageIO
org.apache.fop.image.loader.batik.PreloaderWMF
org.apache.fop.image.loader.batik.PreloaderSVG

but after gradle task for making uber jar the file contains only:

org.apache.fop.image.loader.batik.PreloaderWMF
org.apache.fop.image.loader.batik.PreloaderSVG

this means that at runtime we don’t have the other preloader image loaded in the classloader.
I try to add the missing lines after uberjar creation finished and create a docker image, all works well.

The next step is fix the uber jar task creation.

Thanks.

Ok, I solved the problem. It’s necessary to modify uber jar task configuration like this:

task buildUberJar(type: CubaUberJarBuilding) {
    logbackConfigurationFile = 'etc/uber-jar-logback.xml'
    singleJar = true
    mergeResources = ['META-INF/services/org.apache.xmlgraphics.image.loader.spi.ImagePreloader',
                      'META-INF/services/org.apache.xmlgraphics.image.loader.spi.ImageLoaderFactory']
    appProperties = ['cuba.automaticDatabaseUpdate': true,
                     'cuba.dataSource.username'    : '',
                     'cuba.dataSource.password'    : '',
                     'cuba.dataSource.dbName'      : '',
                     'cuba.dataSource.host'        : 'postgres',
                     'cuba.dataSource.port'        : '',
                     'cuba.dataSourceProvider'     : 'application']
}

The trick is the property mergeResources.

1 Like