Monthly Archives: March 2015

Java program to convert a image into PowerPoint PPT

Here is the Java program that converts (uploads) images into PowerPoint .PPT file using Apache POI libraries.

Use (download) the following combination of Apache POI libraries,

poi-3.11-20141221.jar and poi-scratchpad-3.8.jar

Let’s jump into the program

package com.athavan.examples;

import java.awt.Dimension;

import org.apache.poi.hslf.model.Fill;
import org.apache.poi.hslf.model.Picture;
import org.apache.poi.hslf.model.Slide;
import org.apache.poi.hslf.usermodel.SlideShow;

public class CreatePresentation {

private SlideShow ppt;
private Slide slide;
private Fill fill;
private int idx;
private FileOutputStream out;

public static void main(String[] args) {
CreatePresentation cp = new CreatePresentation();
try {
cp.ppt = new SlideShow();
cp.ppt.setPageSize(new Dimension(100, 50));
cp.out = new FileOutputStream(

// use the for loop if you have many images to be uploaded into PPT

// for (int k = 0; k < 1; k++) {
String tmp = "G:\\Saravanan\\Pulse\\Software.PNG";
cp.createSlideWithChart(cp, tmp);
// }
// Save PPT
} catch (Exception fnfe) {

public void createSlideWithChart(CreatePresentation cp, String chartName) {
try {
slide = cp.ppt.createSlide();
fill = slide.getBackground().getFill();
idx = cp.ppt.addPicture(new File(chartName), Picture.PNG);
} catch (FileNotFoundException fnfe) {
} catch (IOException ioe) {


Input File: Software.PNG
Output File: slideshow2.ppt


The above program converts a image into PPT. If we want to upload more images in a folder into PPT, then we can have for loop (which is commented) to achieve the same.

Happy learning and sharing… 🙂


Exception in thread “main” java.lang.NoSuchFieldError: filesystem at org.apache.poi.hslf.HSLFSlideShow.getPOIFSFileSystem(

I was trying to convert a image into PPT using JAVA with the help of Apache POI libraries.

I got the below exception

Exception in thread "main" java.lang.NoSuchFieldError: filesystem
at org.apache.poi.hslf.HSLFSlideShow.getPOIFSFileSystem(
at org.apache.poi.hslf.EncryptedSlideShow.checkIfEncrypted(
at org.apache.poi.hslf.HSLFSlideShow.(
at org.apache.poi.hslf.HSLFSlideShow.(
at org.apache.poi.hslf.HSLFSlideShow.(
at org.apache.poi.hslf.HSLFSlideShow.create(
at org.apache.poi.hslf.usermodel.SlideShow.(
at com.athavan.examples.CreatePresentation.main(


I was using poi-3.11-20141221.jar and poi-scratchpad-3.2-FINAL.jar. That’s went wrong here. Then I replaced the poi scratchpad with latest version, the error gone.

poi-scratchpad-3.8.jar worked well.

poi-3.11-20141221.jar and poi-scratchpad-3.8.jar combinations worked!!

Happy learning and sharing 🙂

java.lang.IllegalStateException: Web app root system property already set to different value: ‘webapp.root’ = [/ApplicationPath1] instead of [/ApplicationPath2] – Choose unique values for the ‘webAppRootKey’ context-param in your web.xml files!

Recently I have deployed two J2EE web application in tomcat web server. Both application uses the log4j. Tomcat server is up and running with no issues.

But at regular interval, one of the J2EE web application was going down. I was digging into the logs and google to find the solution. At regular times, it made us to enter into the tomcat manager page to start the application manually which was down.

Then I have identified the following exception message

java.lang.IllegalStateException: Web app root system property already set to different value: 'webapp.root' = [C:\Program Files\Apache Software Foundation\Tomcat7.0.57\webapps\application1\] instead of [C:\Program Files\Apache Software Foundation\Tomcat7.0.57\webapps\application2\] - Choose unique values for the 'webAppRootKey' context-param in your web.xml files!
at org.springframework.web.util.WebUtils.setWebAppRootSystemProperty(
at org.springframework.web.util.Log4jWebConfigurer.initLogging(
at org.springframework.web.util.Log4jConfigListener.contextInitialized(
at org.apache.catalina.core.StandardContext.listenerStart(
at org.apache.catalina.core.StandardContext.startInternal(
at org.apache.catalina.util.LifecycleBase.start(
at org.apache.catalina.core.ContainerBase.addChildInternal(
at org.apache.catalina.core.ContainerBase.addChild(
at org.apache.catalina.core.StandardHost.addChild(
at org.apache.catalina.startup.HostConfig.deployDirectory(
at org.apache.catalina.startup.HostConfig$
at java.util.concurrent.Executors$ Source)
at Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$ Source)
at Source)

Root cause:

Due to the business requirement, we copied the application1’s code base and created the application2’s code base.
I gave unique names wherever necessary in the configuration files. But still I encountered the above error message. After spending long time, I got the below information about the spring framework

“WARNING: Some containers (like Tomcat) do not keep system properties separate per web app. You have to use unique “webAppRootKey” context-params per web app then, to avoid clashes. Other containers like Resin do isolate each web app’s system properties: Here you can use the default key (i.e. no “webAppRootKey” context-param at all) without worrying. ”

It turns out that the webAppRootKey is a Spring context parameter. It exposes the web application’s root directory as a system property. So, it is the value of the webAppRootKey that provides the name for the system property to use. That’s fine if you’ve just got one webapp in Tomcat. Spring will just choose a default value for this (app.root) and off you go. However, as the warning above notes, Tomcat does not keep system properties separate per webApp. This means that when we get to the second application, the same system property (app.root) is being set to a new value (our second application’s root directory, rather than the first!)

The reason this is occurring at all is that Log4JConfigListener is trying to set the webAppRootKey in both cases. This allows log4J to place log and config files in directories relative to the application root directory, rather than in a fixed path.

I decided the easiest thing was just to use a non-default name for the webAppRootKey for each of my applications.

That is, I fixed this by placing the following context-parameter into each of the web application’s web.xml files:


This fixed the problem

Where can we download Spring Framework Jars?

We can download Spring JARs as .zip from the following link

Cheers 🙂