9

I want to automatically deploy a EAR file build in our continuous integration server to a websphere application server. I looked up the Ant task wsdeploy, but the documentation really isn't helpful at all. I added this to my ant script:

WSDeploy Ant task

<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>

My Problem

I don't know how to specify the remote server address and I'd be glad to get some links to tutorials or maybe a working Ant snippet to deploy an EAR to the websphere server.

We already have some SCP and SSHEXEC tasks running for the portlets, and they're calling the XMLAccess interface to place and start the portlets. Do I have to adapt that scripts for the EAR too or is that a completely wrong way to automatically deploy an EAR file?


UPDATE 2

I rewrote my ant script and now there is no ClassNotFoundException anymore. Still, there is an unexpected behavior: The script wants to use a profile I never specified...

Call to Ant:

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

I want to run all this with EXPECTEDPROFILE, but the error message that is following suggests that there is another profile UNEXPECTEDPROFILE involved.

Output:

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

UPDATE 1

Using wsinstallapp

After reading JoseKs answer I tried to use wsinstallapp to install my application with this Ant target:

<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>

But this is what I get:

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

I don't know why the task is searching for an Eclipse class...

Community
  • 1
  • 1
cringe
  • 13,401
  • 15
  • 69
  • 102
  • Did you ever get this working? – blank Aug 05 '11 at 12:17
  • No, actually we're using a mix of Ant (that copies the EAR with a SCP task) and a jython script that runs on the server machines. The jython is loaded by wsadmin and there we install the server-local EAR file on the node/server. – cringe Aug 08 '11 at 12:44
  • And you have to manually run the script after the SCP task or is the build server on a machine with WAS? I find it ridiculous that we can't do automated deployment from a build server. – blank Aug 08 '11 at 13:15
  • No, we scp the EAR artifact and the jython script to the WAS server and execute wsadmin from there. In fact, the jython script is based on the examples from http://www.ibm.com/developerworks/websphere/library/samples/SampleScripts.html – cringe Aug 10 '11 at 06:00
  • 1
    This exception is caused by missing 2 jar files in your classpath. /deploytool/itp/batch2.jar & /deploytool/itp/batchboot.jar – Joe Wilson Nov 02 '13 at 15:20

1 Answers1

6

I believe the ant task for actually deploying the EAR onto the remote Websphere is wsInstallApp as documented 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"/>
JoseK
  • 31,141
  • 14
  • 104
  • 131
  • Thanks for pointing to this task. Unfortunatly the documentation is... I have another problem, but I'll add it to my Q instead of posting it here as a comment. – cringe Jun 28 '10 at 08:12
  • Though this doesnt explain the eclipse classnotfound - Here is a real-life example: http://www.jroller.com/holy/entry/was_6_0_ant_tasks. This and other URLs suggest the "profile" must be passed in first. http://www.theserverside.com/discussions/thread.tss?thread_id=32285 – JoseK Jun 28 '10 at 10:01