HiveMQ

Hivemq-swarm.bat Example Scenario Not Executing

Hello!

I’m trying to walk through the quick start for hivemq-swarm but it is not responding. Oddly enough, when I try to run

C:\hivemq-4.7.2\tools\hivemq-swarm> bin\hivemq-swarm.bat

It returns the same output as running

C:\hivemq-4.7.2\tools\hivemq-swarm> java -h

Which is just the argument options for running java, no information relating to hivemq-swarm specifically.

I’m running on Windows and I want the hivemq-swarm to run the example scenario on a local HiveMQ Broker running in another command prompt, localhost:1883. I have not reconfigured any files, as I’m trying to run this on a fresh installation so I know it’s not my reconfiguring. Have run both with and without admin priveleges, in command prompt and in powershell.

Has anyone encountered this issue before? Any idea what I should try to troubleshoot or reconfigure?

Thanks,
Alexi

Hi Alexi,

nice to see you are interested in HiveMQ Swarm to test your scenario.
Can you please share the output you receive when you execute the hivemq-swarm.bat?

Kind regards,
Finn

1 Like

Hi Finn,

Thanks for the reply! I’ve pasted the output under this post.

Thanks,
Alexi

C:\hivemq-4.7.2\tools\hivemq-swarm\bin>hivemq-swarm.bat
Usage: java [options] <mainclass> [args...]
           (to execute a class)
   or  java [options] -jar <jarfile> [args...]
           (to execute a jar file)
   or  java [options] -m <module>[/<mainclass>] [args...]
       java [options] --module <module>[/<mainclass>] [args...]
           (to execute the main class in a module)
   or  java [options] <sourcefile> [args]
           (to execute a single source-file program)

 Arguments following the main class, source file, -jar <jarfile>,
 -m or --module <module>/<mainclass> are passed as the arguments to
 main class.

 where options include:

    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
    --class-path <class search path of directories and zip/jar files>
                  A ; separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -p <module path>
    --module-path <module path>...
                  A ; separated list of directories, each directory
                  is a directory of modules.
    --upgrade-module-path <module path>...
                  A ; separated list of directories, each directory
                  is a directory of modules that replace upgradeable
                  modules in the runtime image
    --add-modules <module name>[,<module name>...]
                  root modules to resolve in addition to the initial module.
                  <module name> can also be ALL-DEFAULT, ALL-SYSTEM,
                  ALL-MODULE-PATH.
    --enable-native-access <module name>[,<module name>...]
                  modules that are permitted to perform restricted native operations.
                  <module name> can also be ALL-UNNAMED.
    --list-modules
                  list observable modules and exit
    -d <module name>
    --describe-module <module name>
                  describe a module and exit
    --dry-run     create VM and load main class but do not execute main method.
                  The --dry-run option may be useful for validating the
                  command-line options such as the module system configuration.
    --validate-modules
                  validate all modules and exit
                  The --validate-modules option may be useful for finding
                  conflicts and other errors with modules on the module path.
    -D<name>=<value>
                  set a system property
    -verbose:[class|module|gc|jni]
                  enable verbose output for the given subsystem
    -version      print product version to the error stream and exit
    --version     print product version to the output stream and exit
    -showversion  print product version to the error stream and continue
    --show-version
                  print product version to the output stream and continue
    --show-module-resolution
                  show module resolution output during startup
    -? -h -help
                  print this help message to the error stream
    --help        print this help message to the output stream
    -X            print help on extra options to the error stream
    --help-extra  print help on extra options to the output stream
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions with specified granularity
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:jdwp
                  see also -agentlib:jdwp=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
                  show splash screen with specified image
                  HiDPI scaled images are automatically supported and used
                  if available. The unscaled image filename, e.g. image.ext,
                  should always be passed as the argument to the -splash option.
                  The most appropriate scaled image provided will be picked up
                  automatically.
                  See the SplashScreen API documentation for more information
    @argument files
                  one or more argument files containing options
    -disable-@files
                  prevent further argument file expansion
    --enable-preview
                  allow classes to depend on preview features of this release
To specify an argument for a long option, you can use --<name>=<value> or
--<name> <value>.


C:\hivemq-4.7.2\tools\hivemq-swarm\bin>

I was able to narrow it down to this line in hivemq-swarm.bat:

"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %HIVEMQ_SWARM_OPTS% -classpath "%CLASSPATH%" com.hivemq.swarm.Main %*

When I echo each of the variables I get:

%JAVA_EXE% = java.exe
%DEFAULT_JVM_OPTS% = “–add-opens” “java.base/java.lang=UNNAMED” “-Dswarm.home=C:\hivemq-4.7.2\tools\hivemq-swarm”
%JAVA_OPTS% does not exist (echo outputs “ECHO is off”)
%HIVEMQ_SWARM_OPTS% does not exist
%CLASSPATH% = C:\hivemq-4.7.2\tools\hivemq-swarm\lib*

I’m concerned that %JAVA_OPTS% and %HIVEMQ_SWARM_OPTS% don’t exist at execution time. Is this normal? What do people get under normal operation?

Thanks,
Alexi

Hi Alexi,

JAVA_OPTS and HIVEMQ_SWARM_OPTS are optional. In order to see exactly what you command line looks like, you can echo it before running it. To do so, update your hivemq-swarm.bat like this:

@rem Execute hivemq-swarm
set commandline="%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %HIVEMQ_SWARM_OPTS%  -classpath "%CLASSPATH%" com.hivemq.swarm.Main %*
echo "Executing the command:"
echo "%commandline%"
%commandline%

Kind regards,
Dasha from HiveMQ Team

1 Like

Hi Dasha,

When I echoed the command line I got:

"java.exe" "--add-opens" "java.base/java.lang=ALL-UNNAMED" "-Dswarm.home=C:\hivemq-4.7.2\tools\hivemq-swarm\"    -classpath "C:\hivemq-4.7.2\tools\hivemq-swarm\lib\*" com.hivemq.swarm.Main 

Running this in the command prompt alone (without running the .bat) resulted in the same weird java output noted above.
This command seemed off to me so I tried removing all the quotations and running this in command prompt:

java.exe --add-opens java.base/java.lang=ALL-UNNAMED -Dswarm.home=C:\hivemq-4.7.2\tools\hivemq-swarm\ -classpath C:\hivemq-4.7.2\tools\hivemq-swarm\lib\* com.hivemq.swarm.Main

And the swarm actually runs properly! Is there something wrong with this operation or is this a safe fix? Were the quotation marks in the .bat file just typos?

Thanks,
Alexi

Hi Alexi,

Thank you for the update – I am very glad the the swarm runs properly. You can use this fix safely.

Kind regards,
Dasha from HiveMQ Team

1 Like

Hi Dasha,

Thank you very much for your help.

Thanks,
Alexi