1

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
Sathiamoorthy
  • 8,831
  • 9
  • 65
  • 77

2 Answers2

0

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.
Rafael Winterhalter
  • 42,759
  • 13
  • 108
  • 192
0

Thanks Rafael - Now Solved! I went back over that information and I now understand what was happening. To run successfully Word/Excel needs a valid user profile - in my case it was the profile that Word/Excel was installed with. Word/Excel needs permission to write temporary files to %USERPROFILE%\Local\Temp. When a program is Run as Administrator it appears that either the system tries to write to a non-existent location or the system does not have permission to the original %USERPROFILE%\Local\Temp.

In addition to the documents4j documentation one additional step was required.

This was outlined in an older post on this subject on 10th Oct 2018 from Céderic Missinne: Automating MS Word in Server 2012 R2

Start - Run - mmc comexp.msc /32
Expand: Component Services –> Computers – My Computer – DCOM Config
Search for: Microsoft Word 97 –> 2003 Document
RMC – Properties – Go to tab: Identity Set from “The launching user” to “This user”.
Use a “local Administrator account” which has once signed in to the server machine and 
has opened Word at least once in an interactive desktop.

In my case I changed from 'The interactive user' to 'The launching user'.

The StandaloneServer then worked successfully when Run As Administrator.

This also solved a similar problem where I have the StandaloneServer running as a Windows Service using Apache Procrun!

Thanks again Rafael!