Generating Jasperreports in a background job

Discuss all problems you have with Servoy here. It might help to mention the Servoy version and Operating System version you are using

Generating Jasperreports in a background job

Postby g.collette » Wed Apr 24, 2024 10:27 am

Dear Servoy,

We are experiencing some issues/difficulties with the generation of reports through a headless client.
Our current production setup is synchronous execution, but this can add anywhere from 10s tot a few minutes where the UI is blocked.

We are trying to move it to a background job, however any attempt at using blobs or base64 for images has been less than successful.

The funky part is that the headless client when ran in the IDE works as expected, an image appears on the report.
However, when running in our test environment (a docker container built through Servoy cloud pipeline) the resulting report has "null" instead of an image.
I've double checked, the data is there. I am seeing differing behaviour between the developer's application server and your docker template's application server in this regard.

The imageExpression line in our report for adding images is:
<imageExpression class="java.io.InputStream"><![CDATA[new java.io.ByteArrayInputStream(java.util.Base64.getDecoder().decode($F{SOME_FOUNDSET_BASED_BASE64_IMAGE_SOURCE}.getBytes()))]]></imageExpression>

I would really appreciate any tips and best practice information regarding the use of blobs in jasperreports with the JSFoundset.
g.collette
 
Posts: 6
Joined: Fri Dec 08, 2023 2:58 pm

Re: Generating Jasperreports in a background job

Postby Gabi Boros » Wed Apr 24, 2024 10:58 am

what if you use java.awt.Image as type instead of java.io.InputStream for the imageExpression, and load it like:
<imageExpression class="java.awt.Image"><![CDATA[net.sf.jasperreports.engine.util.JRImageLoader.getInstance(DefaultJasperReportsContext.getInstance()).loadAwtImageFromBytes((byte[])$F{product_image})]]> ?
Gabi Boros
Servoy
Gabi Boros
 
Posts: 404
Joined: Tue Jun 26, 2007 4:03 pm
Location: Timisoara, Romania

Re: Generating Jasperreports in a background job

Postby g.collette » Wed Apr 24, 2024 3:21 pm

Sadly this is not a solution and behaves exactly the same.

Something weird also seems to be going on with upgrading to newer versions of the plugin through jenkins-customs/custom-jars/plugins/*.
I get errors like classes from itext (com.lowagie.*) not being found (like FopGlyphProcessor) in the execution.
As if not all the dependencies are shipped with the docker container image or the dependency resolution is incorrect.
g.collette
 
Posts: 6
Joined: Fri Dec 08, 2023 2:58 pm

Re: Generating Jasperreports in a background job

Postby Gabi Boros » Wed Apr 24, 2024 4:08 pm

which version of Servoy and jasper do you use?
so, in the IDE it works, no errors, but when deployed (so a war file) it doesn't; can you check for all errors you see when deployed? maybe an exception prevents the image to be displayed...
Gabi Boros
Servoy
Gabi Boros
 
Posts: 404
Joined: Tue Jun 26, 2007 4:03 pm
Location: Timisoara, Romania

Re: Generating Jasperreports in a background job

Postby g.collette » Wed Apr 24, 2024 5:30 pm

Servoy version is previous LTS, aka 2022.3.8.
The plugin was on 6.17, then 6.17_01 and now I managed to get "Servoy JasperReports Plugin 2022.3.1_6.20.0" to work.
But I'm back to square one.

I've been able to ascertain where it goes wrong by running the report in both from client interaction and background job.
When executed from the ngClient in the browser, the resulting PDF contains the expected image.
When executed from the headlessclient originating from a background job, the resulting image is not an image but the text "null".
This seems headless client/background job specific. Which makes the generation of PDFs from a background job impossible for now.
I'm going to open an official ticket in Jira, but before that I'll try to execute the same with a built from version 2023.3.6 to rule out "outdated software bugs".
g.collette
 
Posts: 6
Joined: Fri Dec 08, 2023 2:58 pm

Re: Generating Jasperreports in a background job

Postby mboegem » Thu Apr 25, 2024 12:21 pm

Hi g.collette,

this sounds like an issue with images we've encountered with Aspose for Word library.

Try adding this java option to your Tomcat instance:
Code: Select all
-Djava.awt.headless=true


After that restart Tomcat of course.

Hope that helps.
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1754
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Generating Jasperreports in a background job

Postby g.collette » Thu Apr 25, 2024 1:16 pm

Ah, I suppose I will need to add that to the fargate task definition in the environment properties under JAVA_OPTS and not CATALINA_OPTS?
g.collette
 
Posts: 6
Joined: Fri Dec 08, 2023 2:58 pm

Re: Generating Jasperreports in a background job

Postby mboegem » Thu Apr 25, 2024 1:43 pm

This worked:

In tomcat/bin folder
Open: tomcat9w.exe
Java tabpanel > Java options, add:
-Djava.awt.headless=true
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1754
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Generating Jasperreports in a background job

Postby g.collette » Thu Apr 25, 2024 2:08 pm

We run our application in AWS in a docker container obtained through the servoy admin cloud pipelines.
I tried running with both Java_OPTS and CATALINA_OPTS with -Djava.awt.headless=true, but lamentably to no avail.
Still, thank you for your input and suggestions.

I've opened an official ticket in Jira.
g.collette
 
Posts: 6
Joined: Fri Dec 08, 2023 2:58 pm


Return to Discuss possible Issues and Bugs

Who is online

Users browsing this forum: No registered users and 1 guest