In my day job we use Jasper Reports to generate PDF reports as part of the output from a diagnostic instrument. Overall it is a nice tool but one issue that has plagued me is that by default the rendering occurs on another thread which is problematic when some of your inputs are JPA entities. After some deep diving, this is because Jasper takes advantage of context switching to know when content overflows and requires some layout adjustments like a page break. Jasper does provide an alternative implemenation based upon a continuation library called Javaflow.
Documentation is sparse, but basically you swap out the japserreports artifact with the jasperreports-javaflow artifact. They don’t currently publish the javaflow variant to Maven Central so you’ll need to acquire it yourself from their releases. One other requirement is that you’ll need the Javaflow library. Their wiki and forum posts refer you to a defunt Apache Commons Javaflow project of which the project is not actually using. Instead you’ll want to grab the actively maintained tescalate-javaflow api artifact to be available at least on your applications runtime classpath.
Now with those details out of the way you can actually use jasper reports within a single thread and have them behave properly within a JPA transaction.