Thread leak with ImageLoadWorker in Flying Saucer jar

Problem :

If you have used Flying Saucer \ HTMLRenderer jar in your code for “HTML to PDF” conversion then you have faced Thread leak in ImageLoadWorker and eventually it make your system down. Further if you will monitor your system in Java melody or Jmeter you will find out that each request for “HTML to PDF” conversion is leaving 5 threads open.

Solution :

To solve this problem you just need to put a properties file( Eg : htmlrenderer.properties) some where in your system which is reachable from your application. Put below entries in properties file.

xr.image.background.loading.enable=false
xr.image.background.workers=0

In your code at start of the application set the path of this file in system properties like given below.

//Absolute path of that file
System.setProperties("xr.conf","D:\\htmlrendererconf\\htmlrenderer.properties");

As you have set workers count zero in properties file, it will generate zero unused threads and your problem is solved.

Other related posts are :
HTML to PDF conversion in JAVA | HTML to PDF example in JAVA
ThreadPoolExecutor and BlockingQueue with an example
Concept of AOP (Aspect oriented programming) every spring programmer use without knowing about it .
Top 10 spring interview questions and their answers. Spring basic concepts.

Please share this posts on Facebook,Linkeedin,Google+,Twitter by clicking on below icons.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s