【问题标题】:Using Ant to deploy EAR to remote websphere application server使用 Ant 将 EAR 部署到远程 websphere 应用服务器
【发布时间】:2011-03-08 06:18:31
【问题描述】:

我想将在我们的持续集成服务器中构建的 EAR 文件自动部署到 websphere 应用程序服务器。我查了 Ant 任务 wsdeploy,但 documentation 真的一点用都没有。我将此添加到我的 ant 脚本中:

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 sn-p 来将 EAR 部署到 websphere 服务器。

我们已经为 portlet 运行了一些 SCP 和 SSHEXEC 任务,它们正在调用 XMLAccess 接口来放置和启动 portlet。我是否也必须为 EAR 调整该脚本,或者这是自动部署 EAR 文件的完全错误的方式?


更新 2

我重写了我的 ant 脚本,现在不再有 ClassNotFoundException。尽管如此,还是有一个意外的行为:脚本想要使用我从未指定的配置文件...

调用蚂蚁:

%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 类...

【问题讨论】:

  • 你有没有得到这个工作?
  • 不,实际上我们混合使用了 Ant(通过 SCP 任务复制 EAR)和在服务器机器上运行的 jython 脚本。 jython 由 wsadmin 加载,我们在节点/服务器上安装服务器本地 EAR 文件。
  • 而且您必须在 SCP 任务之后手动运行脚本,还是构建服务器在具有 WAS 的机器上?我觉得我们不能从构建服务器进行自动部署很荒谬。
  • 不,我们将 EAR 工件和 jython 脚本 scp 到 WAS 服务器并从那里执行 wsadmin。其实jython脚本就是基于ibm.com/developerworks/websphere/library/samples/…的例子
  • 这个异常是由于你的类路径中缺少 2 个 jar 文件引起的。 /deploytool/itp/batch2.jar & /deploytool/itp/batchboot.jar

标签: deployment ant websphere


【解决方案1】:

我相信实际将 EAR 部署到远程 Websphere 上的 ant 任务是 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"/>

【讨论】:

猜你喜欢
  • 2010-10-06
  • 1970-01-01
  • 2016-04-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-13
相关资源
最近更新 更多