标题有点误导,因为我知道如何将 artemis 安装为 Windows 服务,根据文档,只需运行
artemis-service.exe install
这对我来说不起作用。我尝试使用 ActiveMQ Artemis 版本 2.31 和 2.29 安装和运行该服务。对于这两个版本,运行该服务都会生成以下日志artemis-service.wrapper.log
2023-10-23 10:19:50,116 DEBUG - Starting WinSW in the service mode
2023-10-23 10:19:50,147 INFO - Starting %JAVA_HOME%\bin\java.exe -XX:+UseParallelGC -Xms512M -Xmx1024M -classpath "C:\Program Files (x86)\apache-artemis-2.31.0\lib\artemis-boot.jar" "-Dartemis.home=C:\Program Files (x86)\apache-artemis-2.31.0" -Dartemis.instance=C:\ArtemisBroker -Ddata.dir=C:\ArtemisBroker\data -Dartemis.instance.etc=C:\ArtemisBroker\etc -Djava.security.auth.login.config=C:\ArtemisBroker\etc\login.config -Dhawtio.disableProxy=true -Dhawtio.realm=activemq -Dhawtio.offline="true" -Dhawtio.role=amq -Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal -Djolokia.policyLocation=file:/C:/ArtemisBroker/etc/jolokia-access.xml org.apache.activemq.artemis.boot.Artemis run
2023-10-23 10:19:50,178 DEBUG - Completed. Exit code is 0
并弹出以下警告:
唯一提供某种提示的来源是 Windows 事件日志,其中包含以下条目:
Service cannot be started. System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at winsw.Util.ProcessHelper.StartProcessAndCallbackForExit(Process processToStart, String executable, String arguments, Dictionary`2 envVars, String workingDirectory, Nullable`1 priority, ProcessCompletionCallback callback, Boolean redirectStdin, LogHandler logHandler, Boolean hideWindow)
at winsw.WrapperService.StartProcess(Process processToStart, String arguments, String executable, LogHandler logHandler, Boolean redirectStdin)
at winsw.WrapperService.OnStart(String[] args)
at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)
我检查了执行命令中的所有路径,但一切似乎都很好。
我唯一注意到的是
<startargument>-Djolokia.policyLocation=%ARTEMIS_INSTANCE_ETC_URI%/jolokia-access.xml</startargument>
和
<env name="ARTEMIS_INSTANCE_ETC_URI" value="file:/C:/ArtemisBroker/etc/"/>
然后artemis-service.xml
解析为
-Djolokia.policyLocation=file:/C:/ArtemisBroker/etc//jolokia-access.xml org.apache.activemq.artemis.boot.Artemis
这似乎有点错误,但改变这一点(删除一个/
)不会改变任何东西。
如何解决这个问题?