When creating a PDF with the VelocityReport plugin, I notice, that the template is not rendered correctly when created from within the developer. Any idea, what could be the problem?
When deployed (WAR file, same plugin though, same template), the PDF is correct and displays the diagram and resolves variables ($!diagramTitle).
When created from within the developer, a text variable is resolved but the internal CSS is displayed as text and the diagram is missing. I checked the plugin properties on admin page, used localhost, 127.0.0.1 and IP address. Nothing helped. What could be the reason?
You say the diagram is missing… perhaps all you need in developer is to add the eastwood.war to your /application_server/server/webapps?
Have you setup your velocityreport.serverURL and velocity.eastwoodURL in servoy-admin to http://localhost:[yourport]/ and http://localhost:[yourport]/eastwood/ respectively?
This looks correct if the port you are using in developer is 8184.
I would need to know more:
What version of Servoy? Of Java? OS?
You said the CSS is “displayed as text”. What do you mean? How do you embed the CSS? Directly inline in the template with a tag? As a href? With an #include or #parse directive?
The diagram is missing: How is it resolved in the html produced by the Velocity filling? - one thing that often helps is to debug the result of plugins.VelocityReport.renderTemplate(template, context) and output this to a file to check what the html that will be used to produce the PDF looks like once evaluated by Velocity, with the variables filled.
See the attached PDF to see, what is meant with “CSS displayed as text”.
The generated diagram of type net.stuff.servoy.plugin.velocityreport.charts.ChartWrapper has the following string representation and can be embedded in an html file and will be displayed correctly: <img src="http://localhost:8184/eastwood/chart?chbh=r&cht=bvg&chxt=y,x&chs=1000x480&chd=t%3A53.0%7C21.0%7C20.0%7C8.0%7C5.0%7C6.0%7C15.0%7C6.0%7C34.0%7C217.0%7C284.0%7C102.0&chxl=0%3A%7C0%7C284%7C1%3A%7CF%7CF-GN%7CF-KI%7CFM-G%7CFM-K%7CFM-N%7CFM-P%7CFM-S%7CF-SP%7CM%7CN%7CS&chco=6B8E8E,B58A60,8FA382,B97A7A,A89ABF,A08373,C5A0B1,9D9D9D,A9B16D,6FA7B5,805D5D,D1B76A&chdl=F%3A+53%7CF-GN%3A+21%7CF-KI%3A+20%7CFM-G%3A+8%7CFM-K%3A+5%7CFM-N%3A+6%7CFM-P%3A+15%7CFM-S%3A+6%7CF-SP%3A+34%7CM%3A+217%7CN%3A+284%7CS%3A+102&chds=0.0,284.0,0.0,284.0,0.0,284.0,0.0,284.0,0.0,284.0,0.0,284.0,0.0,284.0,0.0,284.0,0.0,284.0,0.0,284.0,0.0,284.0,0.0,284.0&ewr=1" border="0" class="chart" width="1000" height="480"></img>
I also attach the template (as image, since I do not find a file opload).
thanks for the information!
I’m afraid I wasn’t able to reproduce though…
I used a clean install of Servoy 2024.3.4.3947_LTS (with embedded java 21), on Windows 11 (I don’t have access to a Mac). I reproduced your template as closely as possible (including CSS) and added a simple chart to the context, used Velocity v3.7.8 and the latest v3.8.4 and in all cases, the PDF was created correctly in Developer.
So, I can only conclude that there is something going on with your installation…
Do you see any exceptions in the servoy log related to plugins loading/jar conflicts/ClassCastException?
I suspect that you might have some conflicts with other jars/plugins… Velocity is using iText 4.2.0 to render the PDF, perhaps you have another version of iText somewhere in your application_server/plugins?
Perhaps you could try and install the Velocity v3.8.4 (making sure you delete the velocityreport.jar + velocityreport.jar.jnlp and velocityreport folder before putting the new files in your application_server/plugins as some jars have been updated to new versions and have a different name, you want to make sure you don’t have more than one version of a jar especially in the velovityreport folder…
Try and remove other non Servoy plugins one by one as well and test again, to see if that helps.
Thank you very much for your effort to reproduce the problem. According to your suggestions, I tried:
iText is in no other plugin
Java 21 installed → no effect
Velocity v3.8.4 installed → IT WORKS!!!
I’m happy.
But the next question comes immediately: There are again conflicting libraries when exporting as WAR. What should I do?
commons-collections-3.2.1.jar: newer version already in servoy_jasperreports/commons-collections-3.2.2.jar
fs-parser.jar: Already in lib folder.
fs-commons.jar: Already in lib folder.
So far, I deleted the duplicates and kept the newest. When doing so now, the problem is back. Probably that was the original problem, dont’n you think? Why only in development environment and not in production?
You should keep these jars in the /plugins/velocityreport folder.
There will be a warning when exporting a war but they will be ignored and the ones in /lib will be used instead.
The problem is that in Developer some of these libraries in /lib are not accessible to plugins, whether it is because they are signed by a Servoy certificate (where the Velocity jars are not) or because the classes are not exported (in the Eclipse context) or both. So in Developer, to be able to access the classes in these jars you need them in /plugins/velocityreport
Once exported all the jars are in the same place and the same context, so the plugin can use the jars that were in /lib in the context of the java application server.