我想在Raspberry Pi上设置MQTT客户端。我的目标是首先使用我的Pi向我在Mac上设置的Mosquitto代理发送“hello world”消息,然后将我的Pi连接到某些传感器并将我收集的数据发送到同一个代理。我目前正在考虑Paho javascript客户端:https://github.com/eclipse/paho.mqtt.javascript。
现在我不得不尝试使用maven来构建和运行Paho存储库中包含的测试。当我运行mvn -e
时,它产生了这些消息:
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.eclipse.paho:paho.javascript:pom:1.0.2
[WARNING] 'version' contains an expression but should be a constant. @ org.eclipse.paho:paho.javascript:${paho.version}, /home/pi/projects/paho.mqtt.javascript/pom.xml, line 7, column 11
[WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.codehaus.mojo:templating-maven-plugin @ org.eclipse.paho:paho.javascript:${paho.version}, /home/pi/projects/paho.mqtt.javascript/pom.xml, line 114, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building paho.javascript 1.0.2
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- minify-maven-plugin:1.7.4:minify (default-minify) @ paho.javascript ---
[WARNING] The source file [mqttws31.js] has the same name as the final file.
[INFO] Starting CSS task:
[INFO] Starting JavaScript task:
[INFO] Processing source file [mqttws31.js].
[INFO] Creating the merged file [mqttws31.js].
[INFO] Creating the minified file [mqttws31.min.js].
Aug 15, 2016 5:25:42 AM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: mqttws31.js:200: WARNING - Parse error. invalid param name "ERROR.KEY"
* @param {error} ERROR.KEY value above.
^
Aug 15, 2016 5:25:42 AM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: mqttws31.js:737: WARNING - Parse error. Non-JSDoc comment has annotations. Did you mean to start it with '/**'?
/*
^
Aug 15, 2016 5:25:42 AM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: mqttws31.js:1667: WARNING - Parse error. invalid param name "connectOptions.timeout"
* @param {number} connectOptions.timeout - If the connect has not succeeded within this
^
Aug 15, 2016 5:25:42 AM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: mqttws31.js:1670: WARNING - Parse error. invalid param name "connectOptions.userName"
* @param {string} connectOptions.userName - Authentication username for this connection.
^
Aug 15, 2016 5:25:42 AM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: mqttws31.js:1671: WARNING - Parse error. invalid param name "connectOptions.password"
* @param {string} connectOptions.password - Authentication password for this connection.
^
Aug 15, 2016 5:25:42 AM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: mqttws31.js:1672: WARNING - Parse error. invalid param name "connectOptions.willMessage"
* @param {Paho.MQTT.Message} connectOptions.willMessage - sent by the server when the client
^
Aug 15, 2016 5:25:42 AM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: mqttws31.js:1674: WARNING - Parse error. invalid param name "connectOptions.keepAliveInterval"
* @param {Number} connectOptions.keepAliveInterval - the server disconnects this client if
^
Aug 15, 2016 5:25:42 AM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: mqttws31.js:1677: WARNING - Parse error. invalid param name "connectOptions.cleanSession"
* @param {boolean} connectOptions.cleanSession - if true(default) the client and server
^
Aug 15, 2016 5:25:42 AM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: mqttws31.js:1679: WARNING - Parse error. invalid param name "connectOptions.useSSL"
* @param {boolean} connectOptions.useSSL - if present and true, use an SSL Websocket connection.
^
Aug 15, 2016 5:25:42 AM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: mqttws31.js:1680: WARNING - Parse error. invalid param name "connectOptions.invocationContext"
* @param {object} connectOptions.invocationContext - passed to the onSuccess callback or onFailure callback.
^
Aug 15, 2016 5:25:42 AM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: mqttws31.js:1811: WARNING - Parse error. invalid param name "subscribeOptions.qos"
* @param {number} subscribeOptions.qos - the maiximum qos of any publications sent
^
Aug 15, 2016 5:25:42 AM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: mqttws31.js:1813: WARNING - Parse error. invalid param name "subscribeOptions.invocationContext"
* @param {object} subscribeOptions.invocationContext - passed to the onSuccess callback
^
Aug 15, 2016 5:25:42 AM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: mqttws31.js:1828: WARNING - Parse error. invalid param name "subscribeOptions.timeout"
* @param {number} subscribeOptions.timeout - which, if present, determines the number of
^
Aug 15, 2016 5:25:42 AM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: mqttws31.js:1859: WARNING - Parse error. invalid param name "unsubscribeOptions.invocationContext"
* @param {object} unsubscribeOptions.invocationContext - passed to the onSuccess callback
^
Aug 15, 2016 5:25:42 AM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: mqttws31.js:1874: WARNING - Parse error. invalid param name "unsubscribeOptions.timeout"
* @param {number} unsubscribeOptions.timeout - which, if present, determines the number of seconds
^
Aug 15, 2016 5:25:42 AM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 0 error(s), 15 warning(s)
[INFO] Uncompressed size: 80699 bytes.
[INFO] Compressed size: 29283 bytes minified (7714 bytes gzipped).
[INFO]
[INFO]
[INFO] --- maven-antrun-plugin:1.3:run (generate-js-output) @ paho.javascript ---
[INFO] Executing tasks
[copy] Copying 1 file to /home/pi/projects/paho.mqtt.javascript/target
[delete] Deleting: /home/pi/projects/paho.mqtt.javascript/target/mqttws31-min-2.js
[delete] Deleting: /home/pi/projects/paho.mqtt.javascript/target/mqttws31.min.js
[INFO] Executed tasks
[INFO]
[INFO] --- exec-maven-plugin:1.2.1:exec (install-jsdoc-modules) @ paho.javascript ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.702 s
[INFO] Finished at: 2016-08-15T05:25:44+00:00
[INFO] Final Memory: 6M/16M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (install-jsdoc-modules) on project paho.javascript: Command execution failed. Cannot run program "npm" (in directory "/home/pi/projects/paho.mqtt.javascript"): error=2, No such file or directory -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (install-jsdoc-modules) on project paho.javascript: Command execution failed.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Command execution failed.
at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:367)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
Caused by: java.io.IOException: Cannot run program "npm" (in directory "/home/pi/projects/paho.mqtt.javascript"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
at org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:254)
at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:319)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:610)
at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:352)
... 22 more
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:248)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 29 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
我的问题是如何修复这些错误以及如何使用maven来构建和运行测试?
另外,Paho要求我安装maven和JDK。还有其他更轻松,更简单的MQTT客户端适合Raspberry Pi吗?