2

I am facing issues to run jetty as service using procrun on the target machine I have only jre 1.7 .0_67, I can't install JDK and I don't have JAVA_HOME on the machine here is my script:

@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

and I am getting error:

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

What am I doing wrong please help

Michael Biniashvili
  • 500
  • 1
  • 12
  • 24

1 Answers1

2

As I followed the instructions on this page I got jetty running as a windows service: Startup via Windows Service

The error looks like you have an issue with blanks in the paths. Can you try with 8.3 filename rather than the long name?

The given startup file has quite some blanks in there, it doesn't seem to be the one you actually use because it will not work without removing the blanks, i.e. in the PR_JVMOPTIONS variable.

Can you post the actual one that you use?

anmatr
  • 105
  • 1
  • 9