2010-06-25 124 views
7

我想在我們的持續集成服務器EAR文件構建以在WebSphere Application Server自動部署。我擡頭看看Ant任務wsdeploy,但documentation確實沒有任何幫助。我說這個我ant腳本:使用Ant部署EAR到遠程WebSphere Application Server

WSDeploy Ant任務

<classpath> 
    <fileset dir="${dir.was.plugins}"> 
     <include name="**/*.jar" /> 
    </fileset> 
</classpath> 
<taskdef name="wsdeploy" classname="com.ibm.websphere.ant.tasks.WSDeploy" /> 
<target name="deploy"> 
    <wsdeploy inputFile="myearfile.ear" 
       outputFile="myearfile_fordeployment.ear" 
       classpath="${classpath}" 
       debug="true" 
       ignoreErrors="false" 
       noValidate="false" 
       trace="true" /> 
</target> 

我的問題

我不知道如何指定遠程服務器地址,我會很高興獲得指向教程的鏈接,或者可能是工作的Ant片段將EAR部署到websphere服務器。

我們已經爲portlet運行了一些SCP和SSHEXEC任務,他們正在調用接口來放置和啓動portlet。我是否也必須爲EAR調整腳本,或者是完全錯誤的自動部署EAR文件的方式?


更新2

我改寫了我的Ant腳本,現在也沒有ClassNotFoundException的了。不過,有一個意外的行爲:該腳本要用我從來沒有規定的配置...

呼叫到Ant:

%WAS_HOME%\bin\ws_ant.bat -Duser.install.root="%WAS_HOME%\profiles\EXPECTEDPROFILE" -f buildall.xml "%1" 

我想與EXPECTEDPROFILE運行的這一切,但錯誤信息以下表明還有另一個涉及UNEXPECTEDPROFILE的配置文件。

輸出:

wasListApps: 
    [wsadmin] WASX7023E: Fehler beim Erstellen der "SOAP"-Verbindung zu "MYHOST". Informationen zur Ausnahme: com.ibm.websphere.management.exception.ConnectorNotAvailableException: com.ibm.websphere.management.exception.ConnectorNotAvailableException: ADMC0016E: Das System kann keinen SOAP-Connector erstellen, um die Verbindung zum Host MYHOST an Port MYPORT herzustellen. 
    [wsadmin] WASX7213I: Dieser Script-Client ist mit keinem Serverprozess verbunden. Pr?fen Sie, ob in der Protokolldatei /PATH/TO/UNEXPECTEDT/PROFILE/logs\wsadmin.traceout n?here Einzelheiten enthalten sind. 
    [wsadmin] WASX8011W: Das AdminTask-Objekt ist nicht verfügbar. 
    [wsadmin] WASX7015E: Beim Ausf?hren des Befehls "$AdminApp list" ist eine Ausnahme eingetreten. Informationen zur Ausnahme: 
    [wsadmin] com.ibm.ws.scripting.ScriptingException: WASX7206W: Der Application Management Service ist nicht aktiv. Die Befehle f?r die Anwendungsverwaltung k?nnen nicht ausgef?hrt werden. 
    [wsadmin] Java Result: 103 

更新1

使用wsinstallapp

閱讀JoseKs answer後,我試圖用wsinstallapp安裝我這個Ant目標應用:

<taskdef name="wsInstallApp" classname="com.ibm.websphere.ant.tasks.InstallApplication" classpath="${dir.was.plugins}/com.ibm.ws.runtime_6.1.0.jar" /> 

<target name="deploy" depends="EAR"> 
    <wsInstallApp 
     wasHome="${WAS_HOME}" 
     ear="MYAPPLICATION.ear" 
     options="" 
     properties="" 
     profile="" 
     conntype="SOAP" 
     host="${TargetServer}" 
     port="${TargetPort}" 
     user="${TargetUser}" 
     password="${TargetPwd}" 
     failonerror="true" /> 
</target> 

但是,這是我所得到的:

deploy: 
[wsInstallApp] Anwendung wird installiert [/path/to/MYAPPLICATION.ear]... 
    [wsadmin] Exception in thread "main" java.lang.NoClassDefFoundError: org.eclipse.core.launcher.Main 
    [wsadmin]  at com.ibm.wsspi.bootstrap.WSPreLauncher.launchEclipse(WSPreLauncher.java:335) 
    [wsadmin]  at com.ibm.wsspi.bootstrap.WSPreLauncher.main(WSPreLauncher.java:91) 
    [wsadmin] Caused by: java.lang.ClassNotFoundException: org.eclipse.core.launcher.Main 
    [wsadmin]  at java.net.URLClassLoader.findClass(URLClassLoader.java:496) 
    [wsadmin]  at java.lang.ClassLoader.loadClass(ClassLoader.java:631) 
    [wsadmin]  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) 
    [wsadmin]  at java.lang.ClassLoader.loadClass(ClassLoader.java:597) 
    [wsadmin]  ... 2 more 

我不知道爲什麼任務是尋找一個Eclipse類...

+0

你有沒有得到這個工作? – blank 2011-08-05 12:17:14

+0

不,實際上我們正在使用Ant(它將EAR與SCP任務複製)以及運行在服務器機器上的jython腳本混合使用。 jython由wsadmin加載,我們在服務器上安裝服務器本地EAR文件。 – cringe 2011-08-08 12:44:24

+0

您必須在SCP任務之後手動運行腳本,或者是使用WAS的計算機上的構建服務器?我發現我們無法從構建服務器進行自動化部署是很荒謬的。 – blank 2011-08-08 13:15:05

回答

6

我相信螞蟻任務實際部署的EAR到遠程Websphere是wsInstallApp如記錄here

<taskdef name="wsInstallApp" classname="com.ibm.websphere.ant.tasks.InstallApplication"/> 




<wsInstallApp 
        wasHome="location of websphere installation" 
        ear="the ear file you wish to install" 
        options="the options to pass to the installation process" 
        properties="java properties file containing attributes to set in the JVM System properties" 
        profile="a script file to be executed before the main command or file" 
        conntype="specifies the type of connection to be used." 
        host="the host to connect to" 
        port="the port on the host to connect to" 
        user="user ID to authenticate with" 
     password="password to authenticate with" 
     failonerror="true | false"/> 
+0

感謝您指出此任務。不幸的是,文檔是...我有另一個問題,但我會將它添加到我的Q,而不是在這裏發佈它作爲評論。 – cringe 2010-06-28 08:12:03

+0

雖然這不解釋日食classnotfound - 這是一個現實生活中的例子:http://www.jroller.com/holy/entry/was_6_0_ant_tasks。此網址和其他網址建議必須先通過「配置文件」。 http://www.theserverside.com/discussions/thread.tss?thread_id=32285 – JoseK 2010-06-28 10:01:56

相關問題