HiveMQ as Windows Service

Hi there,

HiveMQ runs perfectly on windows when started by a user, but I can’t get it to run as a service.

Some details on the environment: I’m using Windows 10 Pro (version 1803) and the openjdk version 12.0.1. If any other details are relevant, please let me know.

I’ve unzipped hivemq-ce-2019.1 onto a folder, and within that folder the windows-service (as stated in the official docs), then when I run as admin installService.bat, I get the following output:

  HiveMQ Windows Service Install

"java" -Xmx30m -Djna_tmpdir="C:\dev\tests\hivemq-ce-2019.1\windows-service\bat\/../tmp" -Djava.net.preferIPv4Stack=true -jar "C:\dev\tests\hivemq-ce-2019.1\windows-service\bat\/../wrapper.jar" -i "C:\dev\tests\hivemq-ce-2019.1\windows-service\bat\/../conf/wrapper.conf"
YAJSW: yajsw-stable-12.12
OS   : Windows 10/10.0/amd64
JVM  : Oracle Corporation/12.0.1/c:\dev\tools\jdk-12.0.1/64
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/C:/dev/tests/hivemq-ce-2019.1/windows-service/./lib/extended/groovy/groovy-all-2.4.11.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Nov. 13, 2019 1:56:13 NACHM. org.apache.commons.vfs2.VfsLog info
INFO: Using "C:\Users\bgu\AppData\Local\Temp\vfs_cache" as temporary files store.
************* INSTALLING HiveMQ ***********************

service cmd: java.exe -classpath C:\dev\tests\hivemq-ce-2019.1\windows-service\wrapper.jar -Xrs -Dwrapper.service=true -Dwrapper.working.dir=C:\dev\tests\hivemq-ce-2019.1\bin -Djna_tmpdir=C:\dev\tests\hivemq-ce-2019.1\windows-service\bat\/../tmp -Dwrapper_home=C:\dev\tests\hivemq-ce-2019.1\windows-service\bat\/.. -Dwrapper.config=C:\dev\tests\hivemq-ce-2019.1\windows-service\conf\wrapper.conf -Dwrapper.additional.1x=-Xrs -Djna_tmpdir=C:\dev\tests\hivemq-ce-2019.1\windows-service\bat\..\tmp org.rzo.yajsw.boot.WrapperServiceBooter
Service HiveMQ installed

Then, after rebooting, I expect the HiveMQ service to be up and running, but it’s not When I run the command by hand on the console (as admin again), I get this message:

# java.exe -classpath C:\dev\tests\hivemq-ce-2019.1\windows-service\wrapper.jar -Xrs -Dwrapper.service=true -Dwrapper.working.dir=C:\dev\tests\hivemq-ce-2019.1\bin -Djna_tmpdir=C:\dev\tests\hivemq-ce-2019.1\windows-service\bat\/../tmp -Dwrapper_home=C:\dev\tests\hivemq-ce-2019.1\windows-service\bat\/.. -Dwrapper.config=C:\dev\tests\hivemq-ce-2019.1\windows-service\conf\wrapper.conf -Dwrapper.additional.1x=-Xrs -Djna_tmpdir=C:\dev\tests\hivemq-ce-2019.1\windows-service\bat\..\tmp org.rzo.yajsw.boot.WrapperServiceBooter
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/C:/dev/tests/hivemq-ce-2019.1/windows-service/./lib/extended/groovy/groovy-all-2.4.11.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Nov. 13, 2019 2:29:57 NACHM. org.apache.commons.vfs2.VfsLog info
INFO: Using "C:\Users\bgu\AppData\Local\Temp\vfs_cache" as temporary files store.
java.io.FileNotFoundException: C:\dev\tests\hivemq-ce-2019.1\windows-service\bat\..\log\wrapper.log.lck (Zugriff verweigert)
        at java.base/java.io.FileOutputStream.open0(Native Method)
        at java.base/java.io.FileOutputStream.open(FileOutputStream.java:292)
        at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:235)
        at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:124)
        at org.rzo.yajsw.log.MyFileHandler.initOutputFiles(MyFileHandler.java:267)
        at org.rzo.yajsw.log.MyFileHandler.init(MyFileHandler.java:190)
        at org.rzo.yajsw.log.MyFileHandler.<init>(MyFileHandler.java:789)
        at org.rzo.yajsw.log.MyFileHandler.<init>(MyFileHandler.java:806)
        at org.rzo.yajsw.wrapper.AbstractWrappedProcess.getFileHandler(AbstractWrappedProcess.java:1628)
        at org.rzo.yajsw.wrapper.AbstractWrappedProcess.getWrapperLogger(AbstractWrappedProcess.java:2794)
        at org.rzo.yajsw.wrapper.AbstractWrappedProcess.getInternalWrapperLogger(AbstractWrappedProcess.java:2804)
        at org.rzo.yajsw.wrapper.AbstractWrappedProcess.init(AbstractWrappedProcess.java:279)
        at org.rzo.yajsw.wrapper.WrappedJavaProcess.init(WrappedJavaProcess.java:77)
        at org.rzo.yajsw.app.WrapperMainServiceWin.main(WrapperMainServiceWin.java:148)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        at org.rzo.yajsw.boot.WrapperServiceBooter.main(WrapperServiceBooter.java:46)
WARNING|wrapper|Service HiveMQ|19-11-13 14:29:57|YAJSW: yajsw-stable-12.12
WARNING|wrapper|Service HiveMQ|19-11-13 14:29:57|OS   : Windows 10/10.0/amd64
WARNING|wrapper|Service HiveMQ|19-11-13 14:29:57|JVM  : Oracle Corporation/12.0.1/c:\dev\tools\jdk-12.0.1/64
INFO|wrapper|Service HiveMQ|19-11-13 14:29:58|start delay: 0 

“Zugriff verweigert” means access denied, but I guess you won’t have a problem with that :slight_smile:. Apparently the Java process cannot access the file “…\log\wrapper.log.lck”, which may be caused by the fact that it’s actually a folder. If I rename that folder and create an empty file with the name “wrapper.log.lck”, I get the following behaviour:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/C:/dev/tests/hivemq-ce-2019.1/windows-service/./lib/extended/groovy/groovy-all-2.4.11.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Nov. 13, 2019 2:33:46 NACHM. org.apache.commons.vfs2.VfsLog info
INFO: Using "C:\Users\bgu\AppData\Local\Temp\vfs_cache" as temporary files store.
WARNING|wrapper|Service HiveMQ|19-11-13 14:33:46|YAJSW: yajsw-stable-12.12
WARNING|wrapper|Service HiveMQ|19-11-13 14:33:46|OS   : Windows 10/10.0/amd64
WARNING|wrapper|Service HiveMQ|19-11-13 14:33:46|JVM  : Oracle Corporation/12.0.1/c:\dev\tools\jdk-12.0.1/64
INFO|wrapper|Service HiveMQ|19-11-13 14:33:46|start delay: 0

Which looks better, but still, nothing is running. And this is where I’m stuck. Any ideas? thank you very much.

Hi bgu,

I could reproduce your described behaviour. I created a GitHub issue and an internal ticket. I will update the thread if the cause has been solved.

Thanks for letting us know.

Kind regards,
Michael

1 Like

Thanks a lot. I subscribed the issue on Github as well.

Hello HiveMQ Community,

I’m reviving this thread because it matches an issue that I consistently face when setting up HiveMQ CE.

The issue very often occurs however randomly resolves itself after uninstalling/installing the Windows Service, performing multiple machine reboots or moving system environment variables…

Is this a known issue with Windows Service on HiveMQ CE?

Your guidance would be very much appreciated.

My set up/installation steps are as follows:

-Windows Server 2016 Datacenter (v1607), 64-bit, x64

-OpenJDK 15.0.1

-HiveMQ CE 2020.2 with default config listening on 0.0.0.0:1883

  • Downloaded the latest version of OpenJDK from jdk java net (v15.0.1 as of today) and extract \jdk-15.0.1 to C:\Program Files\Java\jdk-15.0.1
  • Added Environment Variables for JAVA_HOME (pointing to C:\Program Files\Java\jdk-15.0.1) and edited PATH to include C:\Program Files\Java\jdk-15.0.1 and C:\Program Files\Java\jdk-15.0.1\bin moving both up to the top of the list)
  1. Downloaded HiveMQ CE 2020.2 (from https://github.com/hivemq/hivemq-community-edition/) and extracted subfolders (e.g. \bin, \conf) to C:\IOT\HiveMQ

  2. Downloaded Windows-Service (from https://hivemq.com/additional-software/hivemq-windows-service.zip and extracted windows-service subfolder folder extracted to C:\IOT\HiveMQ

  3. Ran run.bat as administrator and confirmed that HiveMQ starts

  4. Ran installService.bat and confirmed that HiveMQ Windows Service is installed

  5. Re-booted machine

8) Result: Service doesn’t start

Services

Windows could not start the HiveMQ service on Local Computer

Error 2: The system cannot find the file specified.

Path to executable:

java.exe -classpath C:\IOT\HiveMQ\windows-service\wrapper.jar -Xrs -Dwrapper.service=true -Dwrapper.working.dir=C:\IOT\HiveMQ\bin -Djna_tmpdir=C:\IOT\HiveMQ\windows-service\bat/…/tmp -Dwrapper_home=C:\IOT\HiveMQ\windows-service\bat/… -Dwrapper.config=C:\IOT\HiveMQ\windows-service\conf\wrapper.conf -Dwrapper.additional.1x=-Xrs -Djna_tmpdir=C:\IOT\HiveMQ\windows-service\bat…\tmp org.rzo.yajsw.boot.WrapperServiceBooter

  1. Re-booted machine multiple more times, uninstalled and re-installed Windows-Service, moved moved Environment Variables up and down and eventually HiveMQ service started

  2. There’s no rhyme or reason that I can tell for how the service eventually starts

Only one screenshot allowed:

Path System Environment Variable
OpenJDK-EnvironmentVariables-2

Yours sincerely,
Johann

hello , there is a solution about this issue ?, i´ve 2 machines with the same problem hivemq 4.33.1. i follow the manual steps but without good results.

heres the message in spanish but is the same issue like thetway
Windows could not start the HiveMQ service on Local Computer
regards

Hi @splata,

The solution is to follow these instructions: HiveMQ Service Troubleshooting Guide.

Let me know if this solves your issue.

Best,
Dasha from The HiveMQ Team