Logstash Error - Oracle"" was unexpected at this time

Hello All

I am trying to set up Logstash on my Local to connect to a hosted Elastic instance. Having followed the steps to set up Logstash - I get the following error when trying to run it.

image

I thought I had multiple versions of Java on my system which might be the cause but I have removed the new versions.

I have taken a look at this thread: Issue on setting up Logstash

but that thread seems to have been locked without resolution.

I also tried out things like setting up the JAVA_HOME to a java external from the Java provided by logstash but nothing seems to have worked. Also to note, even after setting the JAVA_HOME, it seems like my logstash was still using the logstash jdk instead of the JAVA_HOME one.

Can anyone please help?

Thanks

Note: These are my Java Details

image

Testing with 7.12.0 on Windows ..

C:\logstash-7.12.0>bin\logstash.bat -e "input {stdin{}} output {stdout{}}"
"Using bundled JDK: "C:\logstash-7.12.0\jdk\bin\java.exe"""
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
...

That works fine. Now we try

set JAVA_TOOL_OPTIONS=-Djava.vendor="New Oracle"

and we get

C:\logstash-7.12.0>bin\logstash.bat -e "input {stdin{}} output {stdout{}}"
"Using bundled JDK: "C:\logstash-7.12.0\jdk\bin\java.exe"""
Oracle"" was unexpected at this time.

The problem is in setup.bat, where it tries to unset JAVA_TOOL_OPTIONS if it is set

rem do not let JAVA_TOOL_OPTIONS slip in (as the JVM does by default)
if not "%JAVA_TOOL_OPTIONS%" == "" (

that last line evaluates to

if not "-Djava.vendor="New Oracle"" == "" (

which blows up with the error message that you noted. If you cannot unset JAVA_TOOL_OPTIONS you could try editing setup.bat to do

rem do not let JAVA_TOOL_OPTIONS slip in (as the JVM does by default)
if defined JAVA_TOOL_OPTIONS (
  echo "warning: ignoring JAVA_TOOL_OPTIONS=%JAVA_TOOL_OPTIONS%"
  set JAVA_TOOL_OPTIONS=
)

instead of

rem do not let JAVA_TOOL_OPTIONS slip in (as the JVM does by default)
if not "%JAVA_TOOL_OPTIONS%" == "" (
  echo "warning: ignoring JAVA_TOOL_OPTIONS=$JAVA_TOOL_OPTIONS"
  set JAVA_TOOL_OPTIONS=
)
1 Like

Thank You @Badger . Editing the setup.bat file did the trick