I have a problem with my Ant script.
I need to copy a file to Linux server
<copy file="../Ant/lib/jsch-0.1.50.jar" tofile="${ant.home}/lib/jsch-0.1.50.jar" />
<scp todir="${server.user}:${server.password}@${server.dev}:${server.dev.dir.config}" trust="true" verbose="true">
<fileset dir="${src.home}/Config/">
<include name="**/*" />
</fileset>
</scp>
File is copied correctly, but I receive this error:
BUILD FAILED
C:\dev.xml:179: Problem: failed to create task or type scp
Cause: Could not load a dependent class com/jcraft/jsch/Logger
It is not enough to have Ant's optional JARs
you need the JAR files that the optional tasks depend upon.
Ant's optional task dependencies are listed in the manual.
Action: Determine what extra JAR files are needed, and place them in one of:
-C:\Progs\eclipse\plugins\org.apache.ant_1.8.3.v201301120609\lib
-C:\Users\Administrator\.ant\lib
-a directory added on the command line with the -lib argument
How can I dynamically add this JAR in the Ant classloader?
The Exception itself is quite clear and points the reason of the problem:
Action: Determine what extra JAR files are needed, and place them in one of:
-C:\Progs\eclipse\plugins\org.apache.ant_1.8.3.v201301120609\lib
-C:\Users\Administrator\.ant\lib
-a directory added on the command line with the -lib argument
Please check from Library Dependencies
jsch.jar 0.1.50 or later: sshexec and scp tasks (http://www.jcraft.com/jsch/index.html)
If you copy this lib in the ant lib it will solve the issue for the standalone Ant.
And for the case of Eclipse: Go into the Eclipse Preferences, in the Ant/Runtime entry, in the 'Classpath' tab. Use the button 'Add External Jars' to add your jsch.jar to Ant's classpath.
After you have copied jsch-0.1.51.jar to /usr/share/ant/lib/ (or whatever directory you have), make the JAR file readable for all users, not just root. Don't be like me and spend half an hour trying to figure out why it doesn't work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With