【问题标题】:Ant can't find my JAR file? Trying to do an sshexec taskAnt 找不到我的 JAR 文件?尝试执行 sshexec 任务
【发布时间】:2010-09-15 21:20:40
【问题描述】:

我正在尝试在我的 OSX 机器上为 ANT 使用 sshexec 任务,当我尝试运行它时,我收到下面列出的错误。我已经从以下位置下载了 jsch jar 文件:http://www.jcraft.com/jsch/index.html version jsch-0.1.43.jar

我将该文件放入 /usr/share/ant/lib 中,但仍然出现错误。有什么想法吗?

谢谢

<target name="testme" depends="">
 <sshexec host="myhost1" username="${username}" command="ls -la" keyfile="${user.home}/.ssh/id_rsa" />
</target>

我收到以下错误:

BUILD FAILED
/Users/jim/Code/myapp/deploy.xml:16: Problem: failed to create task or type sshexec
Cause: the class org.apache.tools.ant.taskdefs.optional.ssh.SSHExec was not found.
        This looks like one of Ant's optional components.
Action: Check that the appropriate optional JAR exists in
        -/usr/share/ant/lib
        -/Users/jim/.ant/lib
        -a directory added on the command line with the -lib argument

Do not panic, this is a common problem.
The commonest cause is a missing JAR.

更新:::: 我从 apache 安装了新版本的 ANT 并将其放入 /usr/local 并将 jsch 文件移动到 /usr/local/ant/lib 并修复了错误,但是现在当我运行它时我有了一个新版本: ant -f deploy.xml 重启

BUILD FAILED
    /Users/jim/Code/myapp/deploy.xml:20: java.lang.NoSuchMethodError: com.jcraft.jsch.ChannelExec.setExtOutputStream(Ljava/io/OutputStream;)V
        at org.apache.tools.ant.taskdefs.optional.ssh.SSHExec.executeCommand(SSHExec.java:265)
        at org.apache.tools.ant.taskdefs.optional.ssh.SSHExec.execute(SSHExec.java:194)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        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:390)
        at org.apache.tools.ant.Target.performTasks(Target.java:411)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1397)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1366)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1249)
        at org.apache.tools.ant.Main.runBuild(Main.java:801)
        at org.apache.tools.ant.Main.startAnt(Main.java:218)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

这是我的诊断信息:

http://pastebin.org/877058

【问题讨论】:

    标签: java deployment ant


    【解决方案1】:

    看起来是版本兼容性问题,检查jsch的版本是否与ant版本支持的一致。

    【讨论】:

    【解决方案2】:

    在尝试修复旧的 ant 版本时发现了问题,我在调试尝试中留下了这个文件: /Library/Java/Extensions/jsch-0.1.8.jar

    我删除了那个人,一切都很好

    【讨论】:

    • 既然我是对的,您可能应该勾选我的答案并将您的帖子移至评论。那将是正确的做法。
    【解决方案3】:

    下载jsch-0.1.44.jar 并确保已设置trust="true"

    【讨论】:

      【解决方案4】:

      确保您提供 trust="true"

      <sshexec trust="true"
                 host="host_ip"        
                 verbose="true/false"
                 username="UserName"
                 keyfile="KeyFile_location"                     
                 command="some_command">
      </sshexec>
      

      【讨论】:

        猜你喜欢
        • 2012-10-16
        • 1970-01-01
        • 2010-11-17
        • 1970-01-01
        • 2020-02-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-03-03
        相关资源
        最近更新 更多