Error loading report exported to PPTX when deploying to server

We generate our reports using JasperReports 5.6.1 and allow to export the same template to PDF or Powerpoint. When working on a local computer, the downloaded PDF and PPTX file works fine. When we deploy our servers, PDF works fine, but PPTX files cannot be opened. When we run locally, it deploys to tomcat, but when deployed to a server, it launches on Websphere.

Things I tried and noticed:

  • I checked the logs and there are no exceptions or anything to raise any eyebrows.
  • The downloaded file is usually a little larger than the one we get when we run locally.
  • If I changed the file extension to zip and unzipped them. The file structure and file names are the same, and the files actually have the same file size. The content, apparently, differs only in the names of the objects found on each slide.
  • I think this may be a problem with files of type x , which I also tried to export to xlsx, just to find out what will happen and works fine with the same template.
  • I added a static pptx file that was well known and can download it without any problems from the server. I did this to try to fix the server configuration from the problem, and felt that it worked, I assume that this is something with my code, just not sure what.

Here is the code for where we write the answer:

 if ("xlsx".equals(type)) { response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setHeader("Content-Disposition", "attachment; filename=" + filename + ".xlsx"); } else if ("pptx".equals(type)) { response.setContentType("application/vnd.openxmlformats-officedocument.presentationml.presentation"); response.setHeader("Content-Disposition", "attachment; filename=" + filename + ".pptx"); response.setCharacterEncoding("UTF-8"); } else { response.setContentType("application/pdf"); response.setHeader("Content-Disposition", "attachment; filename=" + filename + ".pdf"); } try (final ByteArrayOutputStream reportResult = reportsService.generateReport( getDeal(userId, dealId, sessionStore), getScenarioModel(userId, dealId, scenarioId, sessionStore), reportId, type)) { configureResponse(response, type, reportResult, dealId + "-" + scenarioId); // Write to http response reportResult.writeTo(response.getOutputStream()); } response.flushBuffer(); 

I have run out of troubleshooting ideas, and not being able to reproduce them locally, it's hard for me to diagnose.

+7
java jasper-reports powerpoint
source share
1 answer

This is a little shot in the dark, but are you sure that the mime type is correctly configured in your WebSphere instances? (I understand that setting the content type in the response should eliminate the requirement for the web server to be configured for this MIME type, but it is still WebSphere ;-))

I bet that PDF is a customized MIME type, but PPTX is not. You can check?

  • Login to WAS Admin Console
  • Go to virtual hosts
  • Click a MIME Type Link

( here is a more detailed technot )

IIRC, unlike Tomcat, which (due to the lack of a better term) is an all-in-one combined container and servlet container, WebSphere has a separate HTTP stack (along with a separate JVM for each application), so it’s not surprising that there may be required a configuration that would not be for simpler containers.

+3
source share

All Articles