Ant scp task not working, even with jsch on ant/lib

試著忘記壹切 提交于 2019-12-18 12:52:21

问题


I need to copy a war file via scp.

I have added the jsch-0.1.42.jar to $ANT_HOME/lib but I'm still getting this error:

Cause: the class org.apache.tools.ant.taskdefs.optional.ssh.Scp was not found. This looks like one of Ant's optional components.

This is the result of running ant -diagnostics just in case:

http://gist.github.com/320859


回答1:


This looks like your problem, from the top of the diagnostics:

optional tasks : not available

Your $ANT_HOME/lib directory is missing ant-jsch.jar, which is where your missing class comes from.

I'm not sure how this happened - I always install Ant from the ZIP file on the download site, which includes all the optional tasks. If you installed Ant from a Linux package, try checking to see if there is a separate package for the optional tasks.

Once you get the optional tasks installed, I would delete the old version of jsch.jar as @trashgod suggests.




回答2:


I had the same problem and fixed it! Remember, you need BOTH ant-jsch.jar (native from ant or java installation) and updated jsch (in my case it was jsch-0.1.46.jar) in ant lib dir.

You need to load the newest jsch.jar from http://www.jcraft.com/jsch/ and add to libs folder (but not replace ant-jsch.jar).

The mistake a lot of developers do:

  1. ant-jsch.jar out of date (in this case <scp> task is unknown for ant)
  2. Adjust libraries versions, so ant-jsch.jar and jsch are compatible.
  3. jsch not exists or out of date in ant lib dir
  4. Native ant-jsch.jar replaced with jsch (i did it...)

In last 2 cases ant knows scp command, but says it is not available.




回答3:


I added ant-jsch and jsch dependencies in maven pom.xml or including those two jars in build solved the issue.



来源:https://stackoverflow.com/questions/2374105/ant-scp-task-not-working-even-with-jsch-on-ant-lib

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!