javawindowspowerpointjacob

How to have a Java application invoke PowerPoint through JACOB when started as a service?


I have a Java web application which has to transcode PowerPoint slides to images.

For that, this application connects through JACOB to PowerPoint.

To have application working correctly, I deploy it as a service (using nssm). When doing so, it seems i'm unable to transcode slides to images due to the following exception

[1;31m[ERROR]    wisdom-error[0;39m [36m{vert.x-eventloop-thread-0}[0;39m - An exception occurred while processing request POST /skillCenter/{portal}/config/add 
com.jacob.com.ComFailException: Invoke of: Open
Source: Microsoft Office PowerPoint 2007
Description: PowerPoint could not open the file.

    at com.jacob.com.Dispatch.invokev(Native Method) ~[jacob-1.18.jar:na]
    at com.jacob.com.Dispatch.invokev(Dispatch.java:625) ~[jacob-1.18.jar:na]
    at com.jacob.com.Dispatch.callN(Dispatch.java:453) ~[jacob-1.18.jar:na]
    at com.jacob.com.Dispatch.call(Dispatch.java:541) ~[jacob-1.18.jar:na]
    at myCompany.myProject.helpers.loaders.powerpoint.MSPowerPoint.getPresentation(MSPowerPoint.java:58) ~[na:na]
    at myCompany.myProject.helpers.loaders.powerpoint.MSPowerPoint.transform(MSPowerPoint.java:139) ~[na:na]

The ppt file is obviously written in a folder than can be written to by the user which runs the service (me, in the test case).

When checking processes with Process Hacker, I appear as the owner of the process chain starting my application, as well as PowerPoint, which is started through svchost.exe.

So, what is wrong in my case ? How come powerPoint can't access the file when run as a service, when it perfectly can open that file when running as a classical process ?

EDIT 1 I tried using both system account and my account, and both accounts revealed the same flaw.


Solution

  • As it appears, Office programs, when run as a service, require the system local user to have a desktop folder, otherwise they simply bug with those kind of weird errors.

    As a consequence, the solution to such a problem is to create a C:\Windows\SysWOW64\config\systemprofile\Desktop (on Windows 64) folder.