2012-06-21 74 views
1

複製jar文件我有以下幾點:問題與Java日食行家(和螞蟻)上通過ssh

  • 運行在CentOS 6.2eclipse-indigo
  • 我也是在我的系統安裝apache-ant-1.8.4並設置ANT_HOME變量,它在eclipse
  • 在eclipse中,我已經安裝了maven2插件,該插件使用maven-3.0.4版本,該版本安裝在我的系統上(我配置了eclipse以使用它)。

我有我的日食Maven項目,我想每次當我install時間 - (在maven目標) - 它,將產生jar文件中的特定位置被複制我的服務器上 - 通過ssh。爲此,我做了我的pom.xml如下:



    <build> 
    <plugins > 
      <plugin> 
     <groupId > org.apache.maven.plugins </groupId> 
      <artifactId>maven-antrun-plugin</artifactId> 
      <executions> 
       <execution> 
        <phase>install</phase> 
        <configuration> 
         <tasks name="ssh_task"> 
          <taskdef name="scp" 
             classname="org.apache.tools.ant.taskdefs.optional.ssh.Scp" classpathref="/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-jsch.jar" /> 
          <scp file="/absolute/path/to/myfile.jar" 
           todir="[email protected]$10.3.1.1:/remote/location" 
           password="mypass" 
           trusted="true"/> 
         </tasks> 
        </configuration> 
        <goals> 
         <goal>run</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
    </build> 

 

我配置我的pom.xml以這種方式下面這個帖子:

現在的問題是,當我運行install目標與eclipse我得到以下錯誤:

ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:run (default) on project myprojectname: An Ant BuildException has occured: Reference /usr/local/apache-ant/apache-ant-1.8.4/lib/ant-jsch.jar not found. -> [Help 1]

的問題是,ant-jsch.jar是存在的。

問題:您對如何處理我的問題有任何建議嗎?如果你想知道完整的堆棧跟蹤,請告訴我。

編輯:


ant -diagnostics 
------- Ant diagnostics report ------- 
Apache Ant(TM) version 1.8.4 compiled on May 22 2012 

------------------------------------------- 
Implementation Version 
------------------------------------------- 
core tasks  : 1.8.4 in file:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant.jar 

------------------------------------------- 
ANT PROPERTIES 
------------------------------------------- 
ant.version: Apache Ant(TM) version 1.8.4 compiled on May 22 2012 
ant.java.version: 1.6 
Is this the Apache Harmony VM? no 
Is this the Kaffe VM? no 
Is this gij/gcj? no 
ant.core.lib: /usr/local/apache-ant/apache-ant-1.8.4/lib/ant.jar 
ant.home: /usr/local/apache-ant/apache-ant-1.8.4 

------------------------------------------- 
ANT_HOME/lib jar listing 
------------------------------------------- 
ant.home: /usr/local/apache-ant/apache-ant-1.8.4 
commons-logging-1.0.4.jar (38015 bytes) 
jruby-0.9.8.jar (1683526 bytes) 
servlet-api-2.3.jar (77977 bytes) 
serializer-2.7.1.jar (278281 bytes) 
jasper-compiler-4.1.36.jar (184124 bytes) 
commons-logging-api-1.1.jar (44598 bytes) 
bcel-5.1.jar (515920 bytes) 
xml-apis-1.3.04.jar (194354 bytes) 
ant-javamail.jar (13773 bytes) 
ant-commons-logging.jar (9715 bytes) 
jsch-0.1.42.jar (185746 bytes) 
log4j-1.2.14.jar (367444 bytes) 
xalan-2.7.1.jar (3176148 bytes) 
ant-jai.jar (28241 bytes) 
ant-junit4.jar (12923 bytes) 
ant-antlr.jar (11550 bytes) 
jasper-runtime-4.1.36.jar (72397 bytes) 
jai-core-1.1.3.jar (1900631 bytes) 
ant-netrexx.jar (16215 bytes) 
ant-junit.jar (108138 bytes) 
bsh-core-2.0b4.jar (143992 bytes) 
ant-jdepend.jar (14024 bytes) 
asm-commons-2.2.3.jar (15114 bytes) 
regexp-1.2.jar (29871 bytes) 
ant.jar (1941731 bytes) 
regexp-1.3.jar (25429 bytes) 
commons-net-1.4.1.jar (180792 bytes) 
ant-jsch.jar (46176 bytes) 
asm-2.2.3.jar (34832 bytes) 
bsh-2.0b4.jar (281694 bytes) 
ant-apache-oro.jar (45515 bytes) 
antlr-2.7.7.jar (445288 bytes) 
mail-1.4.jar (388864 bytes) 
ant-jmf.jar (12541 bytes) 
asm-tree-2.2.3.jar (16248 bytes) 
js-1.6R7.jar (813521 bytes) 
activation-1.1.jar (62983 bytes) 
ant-testutil.jar (21004 bytes) 
ant-apache-bcel.jar (14548 bytes) 
ant-swing.jar (13497 bytes) 
ant-commons-net.jar (91451 bytes) 
junit-4.8.1.jar (237047 bytes) 
ant-apache-xalan2.jar (8097 bytes) 
jdepend-2.9.1.jar (57933 bytes) 
ant-apache-regexp.jar (9563 bytes) 
maven-artifact-ant-2.0.4-dep.jar (887507 bytes) 
oro-2.0.8.jar (65261 bytes) 
which-1.0.jar (17398 bytes) 
jai-codec-1.1.3.jar (258160 bytes) 
ant-apache-resolver.jar (9886 bytes) 
bsf-2.4.0.jar (113369 bytes) 
NetRexxC.jar (355931 bytes) 
ant-launcher.jar (18429 bytes) 
ant-apache-log4j.jar (8861 bytes) 
ant-apache-bsf.jar (9733 bytes) 
xml-resolver-1.2.jar (84091 bytes) 

------------------------------------------- 
USER_HOME/.ant/lib jar listing 
------------------------------------------- 
user.home: /root 
No such directory. 

------------------------------------------- 
Tasks availability 
------------------------------------------- 
All defined tasks are available 

------------------------------------------- 
org.apache.env.Which diagnostics 
------------------------------------------- 
#---- BEGIN: Which report 
Which.version=Which.java:($Revision: 1.2 $) WhichJar.java:($Revision: 1.2 $) 
java.version=1.6.0_31 
file.encoding=UTF-8 
java.ext.dirs=/usr/java/jdk1.6.0_31/jre/lib/ext:/usr/java/packages/lib/ext 
java.class.path=/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-launcher.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/commons-logging-1.0.4.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jruby-0.9.8.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/servlet-api-2.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/serializer-2.7.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jasper-compiler-4.1.36.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/commons-logging-api-1.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/bcel-5.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/xml-apis-1.3.04.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-javamail.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-commons-logging.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jsch-0.1.42.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/log4j-1.2.14.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/xalan-2.7.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-jai.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-junit4.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-antlr.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jasper-runtime-4.1.36.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jai-core-1.1.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-netrexx.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-junit.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/bsh-core-2.0b4.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-jdepend.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/asm-commons-2.2.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/regexp-1.2.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/regexp-1.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/commons-net-1.4.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-jsch.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/asm-2.2.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/bsh-2.0b4.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-oro.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/antlr-2.7.7.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/mail-1.4.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-jmf.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/asm-tree-2.2.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/js-1.6R7.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/activation-1.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-testutil.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-bcel.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-swing.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-commons-net.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/junit-4.8.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-xalan2.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jdepend-2.9.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-regexp.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/maven-artifact-ant-2.0.4-dep.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/oro-2.0.8.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/which-1.0.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jai-codec-1.1.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-resolver.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/bsf-2.4.0.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/NetRexxC.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-launcher.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-log4j.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-bsf.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/xml-resolver-1.2.jar:/usr/java/jdk1.6.0_31/lib/tools.jar 
os.name=Linux 
java.vendor=Sun Microsystems Inc. 
sun.boot.class.path=/usr/java/jdk1.6.0_31/jre/lib/resources.jar:/usr/java/jdk1.6.0_31/jre/lib/rt.jar:/usr/java/jdk1.6.0_31/jre/lib/sunrsasign.jar:/usr/java/jdk1.6.0_31/jre/lib/jsse.jar:/usr/java/jdk1.6.0_31/jre/lib/jce.jar:/usr/java/jdk1.6.0_31/jre/lib/charsets.jar:/usr/java/jdk1.6.0_31/jre/lib/modules/jdk.boot.jar:/usr/java/jdk1.6.0_31/jre/classes 
java.runtime.name=Java(TM) SE Runtime Environment 
#---- END: Which report 

------------------------------------------- 
XML Parser information 
------------------------------------------- 
XML Parser : com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl 
XML Parser Location: unknown 
Namespace-aware parser : com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser 
Namespace-aware parser Location: unknown 

------------------------------------------- 
XSLT Processor information 
------------------------------------------- 
XSLT Processor : org.apache.xalan.transformer.TransformerIdentityImpl 
XSLT Processor Location: file:/usr/local/apache-ant/apache-ant-1.8.4/lib/xalan-2.7.1.jar 

------------------------------------------- 
System properties 
------------------------------------------- 
java.runtime.name : Java(TM) SE Runtime Environment 
sun.boot.library.path : /usr/java/jdk1.6.0_31/jre/lib/i386 
java.vm.version : 20.6-b01 
ant.library.dir : /usr/local/apache-ant/apache-ant-1.8.4/lib 
java.vm.vendor : Sun Microsystems Inc. 
java.vendor.url : http://java.sun.com/ 
path.separator : : 
java.vm.name : Java HotSpot(TM) Server VM 
file.encoding.pkg : sun.io 
user.country : US 
sun.java.launcher : SUN_STANDARD 
sun.os.patch.level : unknown 
java.vm.specification.name : Java Virtual Machine Specification 
user.dir : /home/artaxerxe 
java.runtime.version : 1.6.0_31-b04 
java.awt.graphicsenv : sun.awt.X11GraphicsEnvironment 
java.endorsed.dirs : /usr/java/jdk1.6.0_31/jre/lib/endorsed 
os.arch : i386 
java.io.tmpdir : /tmp 
line.separator : 

java.vm.specification.vendor : Sun Microsystems Inc. 
os.name : Linux 
ant.home : /usr/local/apache-ant/apache-ant-1.8.4 
sun.jnu.encoding : UTF-8 
java.library.path : /usr/java/jdk1.6.0_31/jre/lib/i386/server:/usr/java/jdk1.6.0_31/jre/lib/i386:/usr/java/jdk1.6.0_31/jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib 
java.specification.name : Java Platform API Specification 
java.class.version : 50.0 
sun.management.compiler : HotSpot Tiered Compilers 
os.version : 2.6.32-220.17.1.el6.i686 
user.home : /root 
user.timezone : Europe/Bucharest 
java.awt.printerjob : sun.print.PSPrinterJob 
file.encoding : UTF-8 
java.specification.version : 1.6 
user.name : root 
java.class.path : /usr/local/apache-ant/apache-ant-1.8.4/lib/ant-launcher.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/commons-logging-1.0.4.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jruby-0.9.8.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/servlet-api-2.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/serializer-2.7.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jasper-compiler-4.1.36.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/commons-logging-api-1.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/bcel-5.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/xml-apis-1.3.04.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-javamail.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-commons-logging.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jsch-0.1.42.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/log4j-1.2.14.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/xalan-2.7.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-jai.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-junit4.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-antlr.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jasper-runtime-4.1.36.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jai-core-1.1.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-netrexx.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-junit.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/bsh-core-2.0b4.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-jdepend.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/asm-commons-2.2.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/regexp-1.2.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/regexp-1.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/commons-net-1.4.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-jsch.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/asm-2.2.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/bsh-2.0b4.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-oro.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/antlr-2.7.7.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/mail-1.4.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-jmf.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/asm-tree-2.2.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/js-1.6R7.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/activation-1.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-testutil.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-bcel.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-swing.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-commons-net.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/junit-4.8.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-xalan2.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jdepend-2.9.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-regexp.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/maven-artifact-ant-2.0.4-dep.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/oro-2.0.8.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/which-1.0.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jai-codec-1.1.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-resolver.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/bsf-2.4.0.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/NetRexxC.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-launcher.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-log4j.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-bsf.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/xml-resolver-1.2.jar:/usr/java/jdk1.6.0_31/lib/tools.jar 
java.vm.specification.version : 1.0 
sun.arch.data.model : 32 
java.home : /usr/java/jdk1.6.0_31/jre 
sun.java.command : org.apache.tools.ant.launch.Launcher -cp -diagnostics 
java.specification.vendor : Sun Microsystems Inc. 
user.language : en 
java.vm.info : mixed mode 
java.version : 1.6.0_31 
java.ext.dirs : /usr/java/jdk1.6.0_31/jre/lib/ext:/usr/java/packages/lib/ext 
sun.boot.class.path : /usr/java/jdk1.6.0_31/jre/lib/resources.jar:/usr/java/jdk1.6.0_31/jre/lib/rt.jar:/usr/java/jdk1.6.0_31/jre/lib/sunrsasign.jar:/usr/java/jdk1.6.0_31/jre/lib/jsse.jar:/usr/java/jdk1.6.0_31/jre/lib/jce.jar:/usr/java/jdk1.6.0_31/jre/lib/charsets.jar:/usr/java/jdk1.6.0_31/jre/lib/modules/jdk.boot.jar:/usr/java/jdk1.6.0_31/jre/classes 
java.vendor : Sun Microsystems Inc. 
file.separator :/
java.vendor.url.bug : http://java.sun.com/cgi-bin/bugreport.cgi 
sun.cpu.endian : little 
sun.io.unicode.encoding : UnicodeLittle 
sun.desktop : gnome 
sun.cpu.isalist : 

------------------------------------------- 
Temp dir 
------------------------------------------- 
Temp dir is /tmp 
Temp dir is writeable 
Temp dir alignment with system clock is -731 ms 

------------------------------------------- 
Locale information 
------------------------------------------- 
Timezone Eastern European Time offset=10800000 

------------------------------------------- 
Proxy information 
------------------------------------------- 
Java1.5+ proxy settings: 
Direct connection 
+0

可以提供螞蟻-diagnostics的輸出,謝謝。 – hovanessyan

+0

@hovanessyan:你能幫我忙嗎?我對'螞蟻'很陌生。 – artaxerxe

+0

如果您的ant配置正確(它位於$ PATH和全部),您應該能夠在終端/控制檯中執行命令「ant -diagnostics」。你是如何安裝Ant的?從分發包還是從zip存檔? – hovanessyan

回答

2

classpathref用於定義對以前定義的屬性的引用。

你應該嘗試定義你的CLASSPATH變量:

<path id="jsch-classpath"> 
     <fileset dir="/usr/local/apache-ant/apache-ant-1.8.4/lib/" includes="ant-jsch.jar"/> 
</path> 

,然後在任務中使用它:

<taskdef name="scp" classname="org.apache.tools.ant.taskdefs.optional.ssh.Scp" classpathref="jsch-classpath" /> 
+1

您需要修改'jsch-classpath'定義。最簡單的方法是聲明'include =「*。jar」'但是如果你需要定義一個更確切的場景,請看http://ant.apache.org/manual/Types/fileset.html。 – Morfic

0

的Maven的安裝階段旨在文物安裝到本地存儲庫,而不是意在將文件傳輸到遠程服務器。如果您試圖將部署和工件部署到Tomcat/JBoss中,那麼最好查看旨在將工件部署到服務器的cargo2-maven-plugintomcat-maven-plugin

Furhtermore我建議maven-wagon-plugin上傳一個神器到服務器,而不是在這種情況下使用Ant,這將使生活更輕鬆。

+0

我不想部署一個神器。我只想做我建議的操作:將我的jar複製到服務器上的某個位置,在該位置正在運行的應用程序將能夠在運行時加載該jar。 – artaxerxe