我正在尝试在安装了Arch linux ARM的Raspberry Pi2模型B上构建Pi4J。除了构建JNI自然库之外,一切都很好。下面是错误消息(和日志的一部分):
[INFO] --- maven-antrun-plugin:1.3:run (build-native-so) @ pi4j-native ---
[INFO] Executing tasks
build-libpi4j.so:
[echo] Building native libpi4j shared library for ABI: hard-float
[sshexec] Connecting to 192.168.178.94:22
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Pi4J :: Parent POM ................................. SUCCESS [01:04 min]
[INFO] Pi4J :: JNI Native Library ......................... FAILURE [ 18.906 s]
[INFO] Pi4J :: Java Library (Core) ........................ SKIPPED
[INFO] Pi4J :: GPIO Extension ............................. SKIPPED
[INFO] Pi4J :: Device Abstractions ........................ SKIPPED
[INFO] Pi4J :: Java Examples .............................. SKIPPED
[INFO] Pi4J :: OSGi Service ............................... SKIPPED
[INFO] Pi4J :: Distribution ............................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:50 min
[INFO] Finished at: 2015-08-11T20:50:37+00:00
[INFO] Final Memory: 11M/29M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:run (build-native-so) on project pi4j-native: An Ant BuildException has occured: The following error occurred while executing this line:
[ERROR] /media/temp/pi4j-arch/pi4j-native/build.xml:10: com.jcraft.jsch.JSchException: Algorithm negotiation fail
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:run (build-native-so) on project pi4j-native: An Ant BuildException has occured: The following error occurred while executing this line:
/media/temp/pi4j-arch/pi4j-native/build.xml:10: com.jcraft.jsch.JSchException: Algorithm negotiation fail
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
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:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
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: An Ant BuildException has occured: The following error occurred while executing this line:
/media/temp/pi4j-arch/pi4j-native/build.xml:10: com.jcraft.jsch.JSchException: Algorithm negotiation fail
at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:131)
at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:98)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
Caused by: The following error occurred while executing this line:
/media/temp/pi4j-arch/pi4j-native/build.xml:10: com.jcraft.jsch.JSchException: Algorithm negotiation fail
at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:508)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:418)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
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.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
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.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at net.sf.antcontrib.logic.IfTask.execute(Unknown Source)
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.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:154)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
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.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:118)
... 23 more
Caused by: /media/temp/pi4j-arch/pi4j-native/build.xml:10: com.jcraft.jsch.JSchException: Algorithm negotiation fail
at org.apache.tools.ant.taskdefs.optional.ssh.SSHExec.execute(SSHExec.java:188)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
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.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
... 53 more
Caused by: com.jcraft.jsch.JSchException: Algorithm negotiation fail
at com.jcraft.jsch.Session.receive_kexinit(Session.java:520)
at com.jcraft.jsch.Session.connect(Session.java:286)
at com.jcraft.jsch.Session.connect(Session.java:150)
at org.apache.tools.ant.taskdefs.optional.ssh.SSHBase.openSession(SSHBase.java:212)
at org.apache.tools.ant.taskdefs.optional.ssh.SSHExec.execute(SSHExec.java:158)
... 66 more
我试了所有我能想出的方法,但我不能使它工作。请帮忙:)
编辑:经过一些进一步的调查,我开始了解这些消息的含义以及它是如何工作的。这是build.xml中给出错误的部分:
<!-- ensure the target directory is empty on the Raspberry Pi -->
<sshexec host="${pi-host}" port="${pi-port}" username="${pi-user}"
password="${pi-password}" trust="true" failonerror="true"
verbose="true" command="rm --recursive --force ${pi-dirBuildTemp}" />
确切地说,它是以"verbose"开头的行。我试着编辑命令,删除它的一部分…没有什么帮助。我试着删除整个代码块,留下其他人(看起来真的像那样),然后错误是在下一个块的最后一行。以下是完整的/media/temp/pi4j-arch/pi4j-native/build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="pi4j-native" default="build-libpi4j.so" basedir=".">
<target name="build-libpi4j.so">
<echo message="Building native libpi4j shared library for ABI: ${pi-abi}"/>
<!-- ensure the target directory is empty on the Raspberry Pi -->
<sshexec host="${pi-host}" port="${pi-port}" username="${pi-user}"
password="${pi-password}" trust="true" failonerror="true"
verbose="true" command="rm --recursive --force ${pi-dirBuildTemp}" />
<!-- ensure the target directory exists on the Raspberry Pi -->
<sshexec host="${pi-host}" port="${pi-port}" username="${pi-user}"
password="${pi-password}" trust="true" failonerror="false"
verbose="true" command="mkdir --parents ${pi-dirBuildTemp}" />
<!-- copy all the necessary source files to the Raspberry Pi -->
<scp todir="${pi-user}:${pi-password}@${pi-host}:${pi-dirBuildTemp}"
port="${pi-port}" trust="true" verbose="true" failonerror="true">
<fileset dir="src/main/native" />
</scp>
<!-- download and compile the 'wiringPi.a' native static library on the Raspberry
Pi platform -->
<sshexec host="${pi-host}" port="${pi-port}" username="${pi-user}"
password="${pi-password}" trust="true" failonerror="true"
verbose="true" command="cd ${pi-dirBuildTemp}; sudo chmod +x wiringpi-build.sh; ./wiringpi-build.sh" />
<!-- compile the 'lib4j.so' JNI native shared library on the Raspberry
Pi platform -->
<sshexec host="${pi-host}" port="${pi-port}" username="${pi-user}"
password="${pi-password}" trust="true" failonerror="true"
verbose="true" command="cd ${pi-dirBuildTemp}; make clean; make all" />
<!-- copy the compiled 'lib4j.so' JNI native shared library back -->
<scp
file="${pi-user}:${pi-password}@${pi-host}:${pi-dirBuildTemp}/libpi4j.so"
todir="${project-build-directory}/${pi-abi}/" port="${pi-port}" trust="true"
verbose="true" failonerror="true">
</scp>
<!-- remove the temporary target directory from the Raspberry Pi -->
<sshexec host="${pi-host}" port="${pi-port}" username="${pi-user}"
password="${pi-password}" trust="true" failonerror="true"
verbose="true" command="rm --recursive --force ${pi-dirBuildTemp}" />
</target>
</project>
也许问题不在于代码本身,而在于ssheexec命令。但我仍然不明白它到底是如何工作的,也不知道问题出在哪里。明天我将尝试删除变量并将值放在那里,只是为了实验。
EDIT2:我测试了它…在同样的地方还是同样的错误……
如果有人有任何想法,请分享。
EDIT3:
非常感谢你,prunge!现在我领先了几步!我做了你建议的两件事,就像第一个一样,它不起作用(但是我在尝试时忘记重启SSH,所以也许它会起作用)。
现在我得到另一个错误,在另一个步骤…当我用谷歌搜索时,我只得到一个结果,但我找不到他们谈论的文件:https://github.com/rm-hull/wiringPi/issues/2我不确定这是否完全相同的问题。
错误如下:
fatal: destination path 'wiringPi' already exists and is not an empty directory.
[UnInstall]
wiringPi Build script
=====================
The wiringPi I2C helper libraries will not be built.
WiringPi library
[UnInstall]
make: Nothing to be done for 'all'.
[Install]
GPIO Utility
[Link]
gpio.o: In function `main':
gpio.c:(.text.startup+0x194): undefined reference to `wiringPiSetupPiFaceForGpioProg'
gpio.c:(.text.startup+0x670): undefined reference to `gertboardSPISetup'
gpio.c:(.text.startup+0x684): undefined reference to `gertboardAnalogWrite'
gpio.c:(.text.startup+0x884): undefined reference to `gertboardSPISetup'
gpio.c:(.text.startup+0x894): undefined reference to `gertboardAnalogRead'
collect2: error: ld returned 1 exit status
Makefile:45: recipe for target 'gpio' failed
make: *** [gpio] Error 1
Make Failed...
Please check the messages and fix any problems. If you're still stuck,
then please email all the output and as many details as you can to
projects@drogon.net
[ant] Exiting /media/temp/pi4j-arch/pi4j-native/build.xml.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Pi4J :: Parent POM ................................. SUCCESS [01:07 min]
[INFO] Pi4J :: JNI Native Library ......................... FAILURE [04:05 min]
[INFO] Pi4J :: Java Library (Core) ........................ SKIPPED
[INFO] Pi4J :: GPIO Extension ............................. SKIPPED
[INFO] Pi4J :: Device Abstractions ........................ SKIPPED
[INFO] Pi4J :: Java Examples .............................. SKIPPED
[INFO] Pi4J :: OSGi Service ............................... SKIPPED
[INFO] Pi4J :: Distribution ............................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 05:41 min
[INFO] Finished at: 2015-08-13T17:01:08+00:00
[INFO] Final Memory: 12M/30M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:run (build-native-so) on project pi4j-native: An Ant BuildException has occured: The following error occurred while executing this line:
[ERROR] /media/temp/pi4j-arch/pi4j-native/build.xml:27: Remote command failed with exit status 1
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:run (build-native-so) on project pi4j-native: An Ant BuildException has occured: The following error occurred while executing this line:
/media/temp/pi4j-arch/pi4j-native/build.xml:27: Remote command failed with exit status 1
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
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:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
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: An Ant BuildException has occured: The following error occurred while executing this line:
/media/temp/pi4j-arch/pi4j-native/build.xml:27: Remote command failed with exit status 1
at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:131)
at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:98)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
Caused by: The following error occurred while executing this line:
/media/temp/pi4j-arch/pi4j-native/build.xml:27: Remote command failed with exit status 1
at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:508)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:418)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
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.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
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.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at net.sf.antcontrib.logic.IfTask.execute(Unknown Source)
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.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:154)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
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.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:118)
... 23 more
Caused by: /media/temp/pi4j-arch/pi4j-native/build.xml:27: Remote command failed with exit status 1
at org.apache.tools.ant.taskdefs.optional.ssh.SSHExec.executeCommand(SSHExec.java:250)
at org.apache.tools.ant.taskdefs.optional.ssh.SSHExec.execute(SSHExec.java:162)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
... 53 more
我真的不明白这是如何工作的,我没有看到任何地方的东西写在注释(在build.xml文件)…下面是build.xml中导致错误的部分:
<!-- download and compile the 'wiringPi.a' native static library on the Raspberry
Pi platform -->
<sshexec host="${pi-host}" port="${pi-port}" username="${pi-user}"
password="${pi-password}" trust="true" failonerror="true"
verbose="true" command="cd ${pi-dirBuildTemp}; sudo chmod +x wiringpi-build.sh; ./wiringpi-build.sh" />
我找不到wiringpi-build.sh…
谢谢克鲁姆
无法通过SSH协议与Pi通信。
如果您还没有,您可能想尝试将无限强度加密策略文件安装到您正在运行Maven的JDK/JRE中。这将允许在通过SSH连接时协商更多算法。
另一种方法是更改Pi上的SSHD配置文件,以允许JDK/JRE支持的某些算法。