spring boot application
maven build tool
aspose total (currently, trial edition)
The application takes pdf, word, excel and image files and converts them to .tiff. The java code for the converters is really simple so i doubt it will be a code problem.
The converter is executed using an http endpoint.
The application is deployed for testing in a linux vm using docker. I’m using “openjdk:11” as base image. The slim edition caused errors (related to fonts i think).
I’m using some test files as input and until now i have found the following cases in which the application fails to convert some files:
- Pdf to tiff conversion when the application receives 2 requests to convert 2 different pdf files to tiff.
The request are sent about the same time using Postman, that is, the are two conversion processes
run at the same time. This causes the following problem:
java.lang.OutOfMemoryError: Java heap space
[994.979s][warning][gc,alloc] http-nio-8080-exec-10: Retried waiting for GCLocker too often allocating 3210508 words
[994.991s][warning][gc,alloc] http-nio-8080-exec-10: Retried waiting for GCLocker too often allocating 4348682 words
2022-04-14 15:54:04.305 ERROR 1 --- [io-8080-exec-10] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.OutOfMemoryError: Java heap space] with root cause
As a result, one pdf file may not be converted successfully.
PS The files get converted successfully and the application doesn’t throw an exception if i convert
them one by one
- Same case for the doc/docx to tiff converter.
Running two conversion processes at the same time causes:
2022-04-15 14:49:44.305 ERROR 1 --- [nio-8080-exec-9] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.OutOfMemoryError: Java heap space] with root cause
java.lang.OutOfMemoryError: Java heap space
PS The files get converted successfully and the application doesn’t throw an exception if i convert
them one by one
- Same case as 2) but for some reason i have got also this output (i didn’t change the code):
2022-04-15 15:14:01.230 ERROR 1 --- [io-8080-exec-10] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.OutOfMemoryError: Java heap space] with root cause
java.lang.OutOfMemoryError: Java heap space
at java.desktop/java.awt.image.DataBufferInt.<init>(DataBufferInt.java:75) ~[na:na]
at java.desktop/java.awt.image.SinglePixelPackedSampleModel.createDataBuffer(SinglePixelPackedSampleModel.java:242) ~[na:na]
at java.desktop/java.awt.image.Raster.createWritableRaster(Raster.java:1005) ~[na:na]
at java.desktop/java.awt.image.BufferedImage.getData(BufferedImage.java:1422) ~[na:na]
at javax.media.jai.RenderedImageAdapter.getData(RenderedImageAdapter.java:153) ~[jai-core-1.1.3.jar!/:na]
at com.sun.media.jai.codecimpl.TIFFImageEncoder.encode(TIFFImageEncoder.java:180) ~[jai-codec-1.1.3.jar!/:na]
at com.sun.media.jai.codecimpl.TIFFImageEncoder.encode(TIFFImageEncoder.java:137) ~[jai-codec-1.1.3.jar!/:na]
at com.aspose.words.internal.zzXlK.zzWPL(Unknown Source) ~[aspose-words-21.10-jdk17.jar!/:21.10.0]
at com.aspose.words.internal.zzXlK.zzWun(Unknown Source) ~[aspose-words-21.10-jdk17.jar!/:21.10.0]
at com.aspose.words.internal.zzZ23.zzWun(Unknown Source) ~[aspose-words-21.10-jdk17.jar!/:21.10.0]
at com.aspose.words.zzXBm.zzhl(Unknown Source) ~[aspose-words-21.10-jdk17.jar!/:21.10.0]
at com.aspose.words.zzXBm.zzWPL(Unknown Source) ~[aspose-words-21.10-jdk17.jar!/:21.10.0]
at com.aspose.words.zzyR.zzWPL(Unknown Source) ~[aspose-words-21.10-jdk17.jar!/:21.10.0]
at com.aspose.words.Document.zzD8(Unknown Source) ~[aspose-words-21.10-jdk17.jar!/:21.10.0]
at com.aspose.words.Document.zzWPL(Unknown Source) ~[aspose-words-21.10-jdk17.jar!/:21.10.0]
at com.aspose.words.Document.save(Unknown Source) ~[aspose-words-21.10-jdk17.jar!/:21.10.0]
at eu.company.asposeconverter.converter.WordToTiffConverter.runConverter(WordToTiffConverter.java:33) ~[classes!/:0.0.1-SNAPSHOT]
at eu.company.asposeconverter.service.AsposeService.convert(AsposeService.java:40) ~[classes!/:0.0.1-SNAPSHOT]
at eu.company.asposeconverter.controller.AsposeController.convert(AsposeController.java:26) ~[classes!/:0.0.1-SNAPSHOT]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.17.jar!/:5.3.17]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.17.jar!/:5.3.17]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.17.jar!/:5.3.17]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.17.jar!/:5.3.17]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.17.jar!/:5.3.17]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.17.jar!/:5.3.17]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067) ~[spring-webmvc-5.3.17.jar!/:5.3.17]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.17.jar!/:5.3.17]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.17.jar!/:5.3.17]
- Running only one conversation process at a time will output the same as in case 2)
when i provide two specific doc files as input.
What should i do either to the spring boot application or the docker image/container?
In the production environment the application should be able to accept about 6-8 requests for conversion at the same time!