javadocuments4j

Client conversion fails when Standalone Server started with Administrator permissions


I am testing various ways to use Documents4j using the shaded jars on Windows 10. I use the following:

SERVER: documents4j-server-standalone-1.1.5-shaded.jar
Command Line: java -jar %~dp0documents4j-server-standalone-1.1.5-shaded.jar http://localhost:9998 -L%~dp0server-log.log -Vall 

CLIENT: documents4j-client-standalone-1.1.5-shaded.jar
Command Line: java -jar %~dp0documents4j-client-standalone-1.1.5-shaded.jar http://localhost:9998 -L%~dp0client-log.log -Vall

In the Client console I enter 0 and the full file path i.e. C:\temp2\Sample.docx

This message is then displayed:Scheduled conversion: C:\temp2\Sample.docx -> C:\temp2\Sample.docx.txt

The conversion is SUCCESSFUL when the Standalone Server is started as the logged in user but FAILS (no conversion file generated) when started with Administrator permissions.

Following are extracts from the logs (attached):

Client Logs

Line 2220

FAILED [ADMINISTRATOR]
2021-04-03 13:39:02,731 WARN  [main] c.documents4j.standalone.StandaloneClient - Converter com.documents4j.job.RemoteConverter@475b7792 is not operational

SUCCESSFUL [USER]
2021-04-03 13:54:49,694 INFO  [main] c.documents4j.standalone.StandaloneClient - Converter com.documents4j.job.RemoteConverter@160c3ec1 is operational

Server Logs

LIne 303
FAILED [ADMINISTRATOR]
2021-04-03 13:39:01,862 TRACE [grizzly-http-server-0] c.d.c.msoffice.MicrosoftWordBridge - Execute no-argument script C:\Users\GRAEME~1.PTB\AppData\Local\Temp\1617419299961-0\word_assert1520023368.vbs
2021-04-03 13:39:01,862 DEBUG [grizzly-http-server-0] org.zeroturnaround.exec.ProcessExecutor - Executing [cmd, /S, /C, ""C:\Users\GRAEME~1.PTB\AppData\Local\Temp\1617419299961-0\word_assert1520023368.vbs""] in C:\Users\GRAEME~1.PTB\AppData\Local\Temp\1617419299961-0.
2021-04-03 13:39:01,872 DEBUG [grizzly-http-server-0] org.zeroturnaround.exec.ProcessExecutor - Started Process[pid=18600, exitValue="not exited"]
2021-04-03 13:39:01,873 TRACE [Thread-4] o.zeroturnaround.exec.stream.StreamPumper - org.zeroturnaround.exec.stream.StreamPumper@4e48de90 started.
2021-04-03 13:39:01,873 TRACE [Thread-5] o.zeroturnaround.exec.stream.StreamPumper - org.zeroturnaround.exec.stream.StreamPumper@786a36ca started.
2021-04-03 13:39:02,150 TRACE [Thread-4] o.zeroturnaround.exec.stream.StreamPumper - org.zeroturnaround.exec.stream.StreamPumper@4e48de90 finished.
2021-04-03 13:39:02,150 TRACE [Thread-5] o.zeroturnaround.exec.stream.StreamPumper - org.zeroturnaround.exec.stream.StreamPumper@786a36ca finished.
2021-04-03 13:39:02,153 DEBUG [WaitForProcess-Process[pid=18600, exitValue="not exited"]] org.zeroturnaround.exec.WaitForProcess - Process[pid=18600, exitValue=-6] stopped with exit code -6

SUCCESSFUL [USER]
2021-04-03 13:54:48,260 TRACE [grizzly-http-server-1] c.d.c.msoffice.MicrosoftWordBridge - Execute no-argument script C:\Users\GRAEME~1.PTB\AppData\Local\Temp\1617420258290-0\word_assert59744299.vbs
2021-04-03 13:54:48,261 DEBUG [grizzly-http-server-1] org.zeroturnaround.exec.ProcessExecutor - Executing [cmd, /S, /C, ""C:\Users\GRAEME~1.PTB\AppData\Local\Temp\1617420258290-0\word_assert59744299.vbs""] in C:\Users\GRAEME~1.PTB\AppData\Local\Temp\1617420258290-0.
2021-04-03 13:54:48,317 DEBUG [grizzly-http-server-1] org.zeroturnaround.exec.ProcessExecutor - Started Process[pid=1724, exitValue="not exited"]
2021-04-03 13:54:48,318 TRACE [Thread-5] o.zeroturnaround.exec.stream.StreamPumper - org.zeroturnaround.exec.stream.StreamPumper@11cbcb1c started.
2021-04-03 13:54:48,318 TRACE [Thread-4] o.zeroturnaround.exec.stream.StreamPumper - org.zeroturnaround.exec.stream.StreamPumper@2c99b36 started.
2021-04-03 13:54:48,750 TRACE [Thread-4] o.zeroturnaround.exec.stream.StreamPumper - org.zeroturnaround.exec.stream.StreamPumper@2c99b36 finished.
2021-04-03 13:54:48,750 TRACE [Thread-5] o.zeroturnaround.exec.stream.StreamPumper - org.zeroturnaround.exec.stream.StreamPumper@11cbcb1c finished.
2021-04-03 13:54:48,753 DEBUG [WaitForProcess-Process[pid=1724, exitValue="not exited"]] org.zeroturnaround.exec.WaitForProcess - Process[pid=1724, exitValue=3] stopped with exit code 3

Also, these WARNINGS appear when the Standalone Client is started:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector (file:/C:/documents4j/documents4j-server-standalone-1.1.5-shaded.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)
WARNING: Please consider reporting this to the maintainers of com.sun.xml.bind.v2.runtime.reflect.opt.Injector
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

Solution

  • As pointed out in the documents4j documentation, you probably need to prepare the user which is not normally set up to run Word. As it says in the documentation:

    1. On a 32-bit system, create the folder C:\Windows\System32\config\systemprofile\Desktop. On a 64-bit system, create the folder C:\Windows\SysWOW64\config\systemprofile\Desktop. Further information can be found on MSDN.
    2. You can manipulate MS Window's registry such that MS Office applications are run with another account than the local service account. This approach is documented on MSDN. Note that this breaks MS Window's sandbox model and imposes additional security threats to the machine that runs MS Office.