elastic / logstash

Logstash - transport and process your logs, events, or other data
https://www.elastic.co/products/logstash
Other
14.22k stars 3.5k forks source link

Logstash does not start on Windows and reports error trying to find classpath #15247

Closed the4amfriend closed 1 year ago

the4amfriend commented 1 year ago

Logstash version: 8.9.0 Logstash installation source: zip archive How is Logstash being run: Via command line

Plugins installed: None

JVM (e.g. java -version): 11.0.20

OS version (uname -a if on a Unix-like system): Windows

Description of the problem including expected versus actual behavior:

Trying to start logstash on Windows causes issues.

Steps to reproduce:

C:\Elastic\logstash-8.9.0>.\bin\logstash.bat "Using bundled JDK: C:\Elastic\logstash-8.9.0\jdk\bin\java.exe" Error: Could not find or load main class jvm_options_parser_failed Caused by: java.lang.ClassNotFoundException: jvm_options_parser_failed

C:\Elastic\logstash-8.9.0>

Please include a minimal but complete recreation of the problem, including (e.g.) pipeline definition(s), settings, locale, etc. The easier you make for us to reproduce it, the more likely that somebody will take the time to look at it.

  1. Install Logstash on windows (make sure to install in a path with no spaces in names)
  2. Try running logstash
  3. It should fail with error that it is unable to find or load the main class for the jvm options parser
jsvd commented 1 year ago

I wasn't able to replicate it in a first attempt:

C:\elastic\logstash-8.9.0>.\bin\logstash.bat
"Using bundled JDK: C:\elastic\logstash-8.9.0\jdk\bin\java.exe"
Sending Logstash logs to C:/elastic/logstash-8.9.0/logs which is now configured via log4j2.properties
[2023-08-10T13:16:42,383][INFO ][logstash.runner          ] Log4j configuration path used is: C:\elastic\logstash-8.9.0\config\log4j2.properties
[2023-08-10T13:16:42,383][INFO ][logstash.runner          ] Starting Logstash {"logstash.version"=>"8.9.0", "jruby.version"=>"jruby 9.3.10.0 (2.6.8) 2023-02-01 107b2e6697 OpenJDK 64-Bit Server VM 17.0.7+7 on 17.0.7+7 +indy +jit [x86_64-mswin32]"}
[2023-08-10T13:16:42,383][INFO ][logstash.runner          ] JVM bootstrap flags: [-Xms1g, -Xmx1g, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djruby.compile.invokedynamic=true, -XX:+HeapDumpOnOutOfMemoryError, -Djava.security.egd=file:/dev/urandom, -Dlog4j2.isThreadContextMapInheritable=true, -Djruby.regexp.interruptible=true, -Djdk.io.File.enableADS=true, --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED, --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED, --add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED, --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED, --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED, --add-opens=java.base/java.security=ALL-UNNAMED, --add-opens=java.base/java.io=ALL-UNNAMED, --add-opens=java.base/java.nio.channels=ALL-UNNAMED, --add-opens=java.base/sun.nio.ch=ALL-UNNAMED, --add-opens=java.management/sun.management=ALL-UNNAMED]
ERROR: Pipelines YAML file is empty. Location: C:/elastic/logstash-8.9.0/config/pipelines.yml
usage:
  bin/logstash -f CONFIG_PATH [-t] [-r] [] [-w COUNT] [-l LOG]
  bin/logstash --modules MODULE_NAME [-M "MODULE_NAME.var.PLUGIN_TYPE.PLUGIN_NAME.VARIABLE_NAME=VALUE"] [-t] [-w COUNT] [-l LOG]
  bin/logstash -e CONFIG_STR [-t] [--log.level fatal|error|warn|info|debug|trace] [-w COUNT] [-l LOG]
  bin/logstash -i SHELL [--log.level fatal|error|warn|info|debug|trace]
  bin/logstash -V [--log.level fatal|error|warn|info|debug|trace]
  bin/logstash --help
[2023-08-10T13:16:42,477][FATAL][org.logstash.Logstash    ] Logstash stopped processing because of an error: (SystemExit) exit
org.jruby.exceptions.SystemExit: (SystemExit) exit
        at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:790) ~[jruby.jar:?]
        at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:753) ~[jruby.jar:?]
        at C_3a_.elastic.logstash_minus_8_dot_9_dot_0.lib.bootstrap.environment.<main>(C:\elastic\logstash-8.9.0\lib\bootstrap\environment.rb:91) ~[?:?]
the4amfriend commented 1 year ago

That's weird, I had to update the setup.bat with setlocal enabledelayedexpansion to get it to work for me. Could it be because of the environmental variables? Or the version of the Windows server?

jsvd commented 1 year ago

Also seems to work on Powershell, even with spaces:

PS C:\a b c d e f g\logstash eight dot nine> .\bin\logstash.bat
"Using bundled JDK: C:\a b c d e f g\logstash eight dot nine\jdk\bin\java.exe"
Sending Logstash logs to C:/a b c d e f g/logstash eight dot nine/logs which is now configured via log4j2.properties
[2023-08-10T13:21:22,491][INFO ][logstash.runner          ] Log4j configuration path used is: C:\a b c d e f g\logstash eight dot nine\config\log4j2.properties
[2023-08-10T13:21:22,491][INFO ][logstash.runner          ] Starting Logstash {"logstash.version"=>"8.9.0", "jruby.version"=>"jruby 9.3.10.0 (2.6.8) 2023-02-01 107b2e6697 OpenJDK 64-Bit Server VM 17.0.7+7 on 17.0.7+7 +indy +jit [x86_64-mswin32]"}
[2023-08-10T13:21:22,507][INFO ][logstash.runner          ] JVM bootstrap flags: [-Xms1g, -Xmx1g, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djruby.compile.invokedynamic=true, -XX:+HeapDumpOnOutOfMemoryError, -Djava.security.egd=file:/dev/urandom, -Dlog4j2.isThreadContextMapInheritable=true, -Djruby.regexp.interruptible=true, -Djdk.io.File.enableADS=true, --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED, --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED, --add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED, --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED, --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED, --add-opens=java.base/java.security=ALL-UNNAMED, --add-opens=java.base/java.io=ALL-UNNAMED, --add-opens=java.base/java.nio.channels=ALL-UNNAMED, --add-opens=java.base/sun.nio.ch=ALL-UNNAMED, --add-opens=java.management/sun.management=ALL-UNNAMED]

which windows version are you using? I tested with Microsoft Windows Server 2019 Datacenter

the4amfriend commented 1 year ago

I'm running Windows Server 2019 standard as well.

jsvd commented 1 year ago

Can you start fresh, by deleting the folder, unpacking Logstash zip again (did you use the .zip package?), and then changing @echo on in bin\setup.bat before running logstash? I'd like to see what's the full set of arguments that is being passed to java.exe

jsvd commented 1 year ago

for example:

C:\a b c d e f g\logstash eight dot nine>"C:\a b c d e f g\logstash eight dot nine\jdk\bin\java.exe" -Xms1g -Xmx1g -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djruby.compile.invokedynamic=true -XX:+HeapDumpOnOutOfMemoryError -Djava.security.egd=file:/dev/urandom -Dlog4j2.isThreadContextMapInheritable=true -Djruby.regexp.interruptible=true -Djdk.io.File.enableADS=true --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.nio.channels=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.management/sun.management=ALL-UNNAMED -cp "C:\a b c d e f g\logstash eight dot nine\vendor\jruby\lib\jruby.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\checker-qual-3.12.0.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\commons-codec-1.15.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\commons-compiler-3.1.0.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\commons-logging-1.2.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\error_prone_annotations-2.11.0.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\failureaccess-1.0.1.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\google-java-format-1.15.0.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\guava-31.1-jre.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\httpclient-4.5.13.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\httpcore-4.4.14.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\j2objc-annotations-1.3.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\jackson-annotations-2.14.1.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\jackson-core-2.14.1.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\jackson-databind-2.14.1.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\jackson-dataformat-cbor-2.14.1.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\jackson-dataformat-yaml-2.14.1.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\janino-3.1.0.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\javassist-3.29.0-GA.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\jsr305-3.0.2.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\jvm-options-parser-8.9.0.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\log4j-1.2-api-2.17.1.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\log4j-api-2.17.1.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\log4j-core-2.17.1.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\log4j-jcl-2.17.1.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\log4j-slf4j-impl-2.17.1.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\logstash-core.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\reflections-0.10.2.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\slf4j-api-1.7.32.jar;C:\a b c d e f g\logstash eight dot nine\logstash-core\lib\jars\snakeyaml-1.33.jar;" org.logstash.Logstash
the4amfriend commented 1 year ago

Reinstalling Logstash actually fixed that, sorry about this!