如何使用procrun将documents4j服务器独立安排为windows服务? [英] How to schedule documents4j server standalone as windows service using procrun?

查看:333
本文介绍了如何使用procrun将documents4j服务器独立安排为windows服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用procrun将documents4j作为Windows服务安排进行RTF到PDF的转换,但它不断抛出以下错误:

I have been trying to schedule the documents4j as windows service using procrun for RTF to PDF conversion but it keeps throwing the following error:

com.documents4j.throwables.ConversionInputException: The sent input is invalid
    at com.documents4j.util.Reaction$ConversionInputExceptionBuilder.make(Reaction.java:159) ~[documents4j-client-standalone-0.3-SNAPSHOT-shaded.jar:na]
    at com.documents4j.util.Reaction$ExceptionalReaction.apply(Reaction.java:75) ~[documents4j-client-standalone-0.3-SNAPSHOT-shaded.jar:na]
    at com.documents4j.ws.ConverterNetworkProtocol$Status.resolve(ConverterNetworkProtocol.java:97) ~[documents4j-client-standalone-0.3-SNAPSHOT-shaded.jar:na]
    at com.documents4j.job.WebserviceRequestFutureWrapper.handle(WebserviceRequestFutureWrapper.java:48) ~[documents4j-client-standalone-0.3-SNAPSHOT-shaded.jar:na]
    at com.documents4j.job.WebserviceRequestFutureWrapper.get(WebserviceRequestFutureWrapper.java:38) ~[documents4j-client-standalone-0.3-SNAPSHOT-shaded.jar:na]
    at com.documents4j.job.WebserviceRequestFutureWrapper.get(WebserviceRequestFutureWrapper.java:13) ~[documents4j-client-standalone-0.3-SNAPSHOT-shaded.jar:na]
    at com.documents4j.job.AbstractFutureWrappingPriorityFuture.run(AbstractFutureWrappingPriorityFuture.java:78) ~[documents4j-client-standalone-0.3-SNAPSHOT-shaded.jar:na]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_31]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_31]
    at java.lang.Thread.run(Unknown Source) [na:1.8.0_31]

我为procrun创建了以下bat文件

I have created the following bat file for procrun

@echo off
set SELF=%CD%
set SERVICE_NAME=PCNService
set SERVICE_URL=
set PR_INSTALL=%SELF%\prunsrv.exe
set PRMGR_INSTALL=%SELF%\prunmgr.exe
 
@REM Service Log Configuration
set PR_LOGPREFIX=%SERVICE_NAME%
set PR_LOGPATH=%SELF%\logs
set PR_STDOUTPUT=auto
set PR_STDERROR=auto
set PR_LOGLEVEL=Debug
 
@REM Path to Java Installation
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_05
set PR_JVM=%JAVA_HOME%\jre\bin\server\jvm.dll
set PR_CLASSPATH=%SELF%\documents4j-server-standalone-0.3-SNAPSHOT-shaded.jar
 
@REM JVM Configuration
set PR_JVMOPTIONS=
@REM Startup Configuration
set JETTY_START_CLASS=com.documents4j.standalone.StandaloneServer

set PR_STARTUP=auto
set PR_STARTMODE=java
set PR_STARTCLASS=%JETTY_START_CLASS%
set PR_STARTMETHOD=start
set PR_STARTPARAMS=http://localhost:9998
 
@REM Shutdown Configuration
set PR_STOPMODE=java
set PR_STOPCLASS=%JETTY_START_CLASS%
set PR_STOPMETHOD=stop
set PR_STOPPARAMS=

if "x%1x" == "xx" goto displayUsage
set SERVICE_CMD=%1
shift
if "x%1x" == "xx" goto checkServiceCmd
:checkServiceCmd
if /i %SERVICE_CMD% == install goto doInstall
if /i %SERVICE_CMD% == delete goto doDelete
if /i %SERVICE_CMD% == stop goto doStop
if /i %SERVICE_CMD% == start goto doStart
if /i %SERVICE_CMD% == monitor goto doMonitor
if /i %SERVICE_CMD% == run goto doRun
if /i %SERVICE_CMD% == console goto doConsole

echo Unknown parameter "%SERVICE_CMD%"
:displayUsage
echo.
echo Usage: service.bat install/start/stop/delete
goto end

:doInstall
rem Install the service
echo Installing the service '%SERVICE_NAME%' ...
%PR_INSTALL% //IS//%SERVICE_NAME% ^
  --DisplayName="%SERVICE_NAME%" ^
  --Install="%PR_INSTALL%" ^
  --Startup="%PR_STARTUP%" ^
  --LogPath="%PR_LOGPATH%" ^
  --LogPrefix="%PR_LOGPREFIX%" ^
  --LogLevel="%PR_LOGLEVEL%" ^
  --StdOutput="%PR_STDOUTPUT%" ^
  --StdError="%PR_STDERROR%" ^
  --JavaHome="%JAVA_HOME%" ^
  --Jvm="%PR_JVM%" ^
  --JvmMs="" ^
  --JvmMx="" ^
  --JvmSs="" ^
  --JvmOptions="%PR_JVMOPTIONS%" ^
  --Classpath="%PR_CLASSPATH%" ^
  --StartMode="%PR_STARTMODE%" ^
  --StartClass="%PR_STARTCLASS%" ^
  --StartMethod="%PR_STARTMETHOD%" ^
  --StartParams="%PR_STARTPARAMS%" ^
  --StopMode="%PR_STOPMODE%" ^
  --StopClass="%PR_STOPCLASS%" ^
  --StopMethod="%PR_STOPMETHOD%" ^
  --StopParams="%PR_STOPPARAMS%" ^
  --Type interactive
 
if not errorlevel 1 goto installed
echo Failed to install "%SERVICE_NAME%" service.  Refer to log in %PR_LOGPATH%
goto end
 
:doStart
rem Starting the service
echo Starting the service '%SERVICE_NAME%' ...
%PR_INSTALL% //ES//%SERVICE_NAME% 
if not errorlevel 1 goto started 
echo Failed to start "%SERVICE_NAME%" service.  Refer to log in %PR_LOGPATH%
goto end

:doStop
rem Stop the service
echo Stopping the service '%SERVICE_NAME%' ...
%PR_INSTALL% //SS//%SERVICE_NAME% 
if not errorlevel 1 goto stopped
echo Failed to stop "%SERVICE_NAME%" service.  Refer to log in %PR_LOGPATH%
goto end

:doDelete
rem Delete the service
echo Deleting the service '%SERVICE_NAME%' ...
%PR_INSTALL% //DS//%SERVICE_NAME% 
if not errorlevel 1 goto deleted
echo Failed to delete "%SERVICE_NAME%" service.  Refer to log in %PR_LOGPATH%
goto end

:doMonitor
rem Monitor the service
echo Monitoring the service '%SERVICE_NAME%' ...
echo Look for the service in the system tray. You can modify the properties in the GUI.
%PRMGR_INSTALL% //MR//%SERVICE_NAME%
goto end

:doRun
rem Run the service
echo Running the service '%SERVICE_NAME%' ...
%PR_INSTALL% //RS//%SERVICE_NAME%
goto end

:doEdit
rem Edit the service
echo Editing the service '%SERVICE_NAME%' ...
%PRMGR_INSTALL% //ES//%SERVICE_NAME%
goto end

:doConsole
rem Running the service as console application
%PR_INSTALL% //TS//%SERVICE_NAME%
goto end

:installed
echo The Service "%SERVICE_NAME%" has been installed
goto logging
goto end

:started
echo The Service "%SERVICE_NAME%" has been started 
goto logging
goto end
 
:deleted
echo The Service "%SERVICE_NAME%" has been deleted
goto end

:stopped
echo The Service "%SERVICE_NAME%" has been stopped
goto logging
goto end

:logging
echo Refer to log in %PR_LOGPATH%

:end
</code>

我能够成功安装jar作为Windows服务并启动/停止它

I able to successfully install the jar as windows service and start/stop it

此外,当类com.documents4j.standalone时。 StandaloneServer通过执行命令行转换正确发生。

Also, when the class com.documents4j.standalone.StandaloneServer is executed via command line the conversions happen correctly.

推荐答案

您是否阅读过使用Word作为Windows服务运行documents4j的信息?

Have you read the information on running documents4j with Word as a Windows service?


在与MS Office转换一起作为Windows服务运行
时,documents4j可能会出现故障。请注意,MS Office在服务上下文中没有正式的
支持执行。当作为服务运行时,MS
Office始终使用MS Window的本地服务帐户启动,
不配置桌面。但是,MS Office预计桌面存在
才能正常运行。如果没有这样的桌面配置,
MS Office将正确启动但无法读取任何输入文件。在允许MS Office在服务上下文中运行的
命令中,有两种
可能的方法,其中更推荐第一种方法:

documents4j might malfunction when run as a Windows service together with MS Office conversion. Note that MS Office does not officially support execution in a service context. When run as a service, MS Office is always started with MS Window's local service account which does not configure a desktop. However, MS Office expects a desktop to exist in order to run properly. Without such a desktop configuration, MS Office will start up correctly but fail to read any input file. In order to allow MS Office to run in a service context, there are two possible approaches of which the first approach is more recommended:

在32位系统上,创建文件夹C:\ Windows \ System32 \ config \systemprofile \Desktop。在64位系统上,
创建文件夹C:\ Windows \SysWOW64 \ config \systemprofile \Desktop。

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.

更多信息可以在MSDN上找到。
您可以操作MS Window的注册表,以便MS Office应用程序使用除本地服务
帐户之外的其他帐户运行。 MSDN上记录了这种方法。请注意,这会破坏MS
Window的沙盒模型,并对运行MS Office的
计算机施加额外的安全威胁。

Further information can be found on MSDN. 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.

这篇关于如何使用procrun将documents4j服务器独立安排为windows服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆