gpt4 book ai didi

java - 使用 procrun 将 jetty 9 作为服务运行

转载 作者:行者123 更新时间:2023-11-30 08:57:42 27 4
gpt4 key购买 nike

我在使用 procrun 将 jetty 作为服务运行时遇到问题在目标机器上我只有jre 1.7 .0_67,我无法安装JDK我的机器上没有 JAVA_HOME这是我的脚本:

@echo off
set SERVICE_NAME="Batch_Server"
set DISPLAY_NAME="Batch Server"
set DESCRIPTION="Batch Server"
set STOPKEY=stopkey
set STOPPORT=50001

set JETTY_JAVA_HOME=%MYAPP_HOME%\jre

set JETTY_HOME=%JETTY_HOME%
set JETTY_BASE=%JETTY_HOME%

set PR_INSTALL=%JETTY_HOME%\service-config\Batch Server.exe
set PR_INSTALL_NEW="%JETTY_HOME%\service-config\Batch Server.exe"

@REM Service Log Configuration
set PR_LOGPREFIX=%SERVICE_NAME%
set PR_LOGPATH=%JETTY_HOME%\logs\service_logs
set PR_STDOUTPUT=auto
set PR_STDERROR=auto
set PR_LOGLEVEL=Debug

@REM Path to Java Installation
set PR_JVM=%JETTY_JAVA_HOME%\bin\server\jvm.dll


set PR_CLASSPATH=%JETTY_HOME%\start.jar

@REM JVM Configuration
set PR_JVMMS=2048
set PR_JVMMX=3072


set PR_JVMOPTIONS=-Duser.dir="%JETTY_BASE%";-Djetty.home="%JETTY_HOME%";- Djetty.base="%JETTY_BASE%"
set PR_JVMOPTIONS=%PR_JVMOPTIONS%;-XX:+PrintGCDetails;- XX:+PrintGCDateStamps;-XX:+UseGCLogFileRotation;-XX:+HeapDumpOnOutOfMemoryError
set PR_JVMOPTIONS=%PR_JVMOPTIONS%;-XX:NumberOfGCLogFiles=5;-XX:GCLogFileSize=100M;-Xloggc:%JETTY_HOME%/logs/jetty.gc;


@REM Startup Configuration
set JETTY_START_CLASS=org.eclipse.jetty.start.Main

set PR_STARTUP=auto
set PR_STARTMODE=jvm
set PR_STARTCLASS=%JETTY_START_CLASS%
set PR_STARTPARAMS=STOP.KEY="%STOPKEY%";STOP.PORT=%STOPPORT%

@REM Shutdown Configuration
set PR_STOPMODE=jvm
set PR_STOPCLASS=%JETTY_START_CLASS%
set PR_STOPPARAMS=-- stop;STOP.KEY="%STOPKEY%";STOP.PORT=%STOPPORT%;STOP.WAIT=10

REM %~1 removing any surrounding quotes (")
%~1%PR_INSTALL_NEW% //IS/%SERVICE_NAME% ^
--DisplayName=%DISPLAY_NAME% ^
--Description=%DESCRIPTION% ^
--Install="%PR_INSTALL%" ^
--Startup="%PR_STARTUP%" ^
--LogPath="%PR_LOGPATH%" ^
--LogPrefix="%PR_LOGPREFIX%" ^
--LogLevel="%PR_LOGLEVEL%" ^
--StdOutput="%PR_STDOUTPUT%" ^
--StdError="%PR_STDERROR%" ^
--Jvm="%PR_JVM%" ^
--JvmMs="%PR_JVMMS%" ^
--JvmMx="%PR_JVMMX%" ^
--JvmOptions="%PR_JVMOPTIONS%" ^
--Classpath="%PR_CLASSPATH%" ^
--StartMode="%PR_STARTMODE%" ^
--StartClass="%JETTY_START_CLASS%" ^
--StartParams="%PR_STARTPARAMS%" ^
--StopMode="%PR_STOPMODE%" ^
--StopClass="%PR_STOPCLASS%" ^
--StopParams="%PR_STOPPARAMS%"

if not errorlevel 1 goto installed
echo Failed to install %SERVICE_NAME% service. Refer to log in %PR_LOGPATH%
goto end

:installed
echo The Service %SERVICE_NAME% has been installed

:end

我收到错误:

2015-01-18 18:05:22 Commons Daemon procrun stderr initialized
java.lang.ExceptionInInitializerError
at java.nio.file.FileSystems.getDefault(Unknown Source)
at org.eclipse.jetty.start.FS.toPath(FS.java:153)
at org.eclipse.jetty.start.config.CommandLineConfigSource.findJettyHomePath(CommandLineConfigSource.java:103)
at org.eclipse.jetty.start.config.CommandLineConfigSource.<init>(CommandLineConfigSource.java:60)
at org.eclipse.jetty.start.Main.processCommandLine(Main.java:589)
at org.eclipse.jetty.start.Main.main(Main.java:111)
Caused by: java.nio.file.InvalidPathException: Illegal char <"> at index 0: "C:\Program Files (x86)\myapp\Data-Batch-Server"
at sun.nio.fs.WindowsPathParser.normalize(Unknown Source)
at sun.nio.fs.WindowsPathParser.parse(Unknown Source)
at sun.nio.fs.WindowsPathParser.parse(Unknown Source)
at sun.nio.fs.WindowsFileSystem.<init>(Unknown Source)
at sun.nio.fs.WindowsFileSystemProvider.<init>(Unknown Source)
at sun.nio.fs.DefaultFileSystemProvider.create(Unknown Source)
at java.nio.file.FileSystems$DefaultFileSystemHolder.getDefaultProvider(Unknown Source)
at java.nio.file.FileSystems$DefaultFileSystemHolder.access$000(Unknown Source)
at java.nio.file.FileSystems$DefaultFileSystemHolder$1.run(Unknown Source)
at java.nio.file.FileSystems$DefaultFileSystemHolder$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.nio.file.FileSystems$DefaultFileSystemHolder.defaultFileSystem(Unknown Source)
at java.nio.file.FileSystems$DefaultFileSystemHolder.<clinit>(Unknown Source)
... 6 more

Usage: java -jar start.jar [options] [properties] [configs]
java -jar start.jar --help # for more information

我做错了什么请帮忙

最佳答案

当我按照此页面上的说明进行操作时,我让 jetty 作为 Windows 服务运行: Startup via Windows Service

该错误看起来像是路径中的空格有问题。您可以尝试使用 8.3 文件名而不是长名称吗?

给定的启动文件中有很多空白,它似乎不是您实际使用的文件,因为如果不删除空白(即在 PR_JVMOPTIONS 变量中),它将无法工作。

你能发布你实际使用的那个吗?

关于java - 使用 procrun 将 jetty 9 作为服务运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28011844/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com