Automating Deployment to IBM WebSphere Portal

Published by Rob on May 22nd, 2008 - in Development, Java, WebSphere Portal

Having an automated deployment procedure is an important goal for any project. This post talks about the the steps taken in making E2 autodeploy to WebSphere Portal in Development.  The below process assumes that the application has been deployed once through other means.

After a friendly pointer from AJ to an article about automating websphere deployment, I decided that the time had come to revisit trying to automate the deployment of our EAR file for E2. I had done bits and pieces of thi in the past using a combination of the WebSphere scripting client, and the WebSphere ant tool (like ant but built with WebSphere bits and pieces). The killer constraint for me is that my client machine didn’t have access to any of the WebSphere binaries (perhaps unsuprisingly Apple and IBM have don’t perfectly interoperate).

In order to work around thi sproblem I ended up leveraging one of the classic protocols (telnet), the websphere scripting client, samba (to mount the application server drives), and a bit of ant to glue it all together. The process outlined below is focused around the deployment of the application E2Application to WebSphere portal.

Step 1: Enable telnet

In Windows Server 2003 this is relatively straightforward. Simply go to your control panel -> services -> Telnet go to the properties, make it automatic and start it.

Step 2: Write scripts to start and stop the app server

I did this using tcl and ended up with the following scripts (the pythonistas may like to use jython to do the same):

stopApplication.jacl

1
 

1
set cell [$AdminControl getCell]<br />       set node [$AdminControl getNode]<br />       set appManager

   

1
[$AdminControl queryNames

   

1
cell=$cell,node=$node,type=ApplicationManager,process=WebSphere_Portal,*]<br />       $AdminControl invoke $appManager stopApplication E2Application<br />

startApplication.jacl

1
&#160;

1
set cell [$AdminControl getCell]<br />       set node [$AdminControl getNode]<br />       set appManager

    

1
[$AdminControl queryNames

   

1
cell=$cell,node=$node,type=ApplicationManager,process=WebSphere_Portal,*]<br />       $AdminControl invoke $appManager startApplication E2Application<br />

Step 3: Write the ant code to compile and copy the application

After the series of standard building tasks, we used a simple copy task to copy the files to the exploded WAR directory on the server. (something like: ${portal.home}/WebSphere/profiles/wp_profile/installedApps/{cell}/{application}.ear/{app_war}.war). Since I develop on a laptop I added in a combination of available and fail task to stop me from accidently creating directories if I hadn’t mounted m

Step 4: use ant to telnet to the server

Make use of the telnet ant task1 to telnet into the server, and run the stop and start server jacl scripts. My Ant targets (passwords scrubbed) are below (excuse the duplication):

1
&#60;target name=&quot;startApplication&quot;&#62;

   

1
&#60;telnet userid=&quot;Administrator&quot; password=&quot;${portal_admin_password}&quot; server=&quot;${portal_server}&quot;&#62;<br />       &#160;&#160;&#160;&#60;read&#62;Administrator&#60;/read&#62;<br />

        <!– change to the IBM AppServer directory –>
        

1
&#60;write&#62;cd \ibm\AppServer\bin&#60;/write&#62;<br />

        

1
&#60;read&#62;AppServer\bin&#60;/read&#62;

        <!– Execute the jacl –>
        

1
&#60;write&#62;wsadmin -conntype SOAP -port 10033

                

1
-username wasadmin -password **** -f startApplication.jacl<br />

        

1
&#60;/write&#62;<br />

        <!– wait for the connected to process message, which will occur on the successful completion of the script –>

1
<br />

        

1
&#60;read&#62;Connected to process&#60;/read&#62;<br />

        

1
&#60;read&#62;AppServer\bin&#60;/read&#62;<br />

    

1
&#60;/telnet&#62;<br />       &#60;/target&#62;

1
<br />       &#60;target name=&quot;stopApplication&quot;&#62;

    

1
&#60;telnet userid=&quot;Administrator&quot; password=&quot;${portal_admin_password}&quot; server=&quot;${portal_server}&quot;&#62;<br />

        

1
&#60;read&#62;Administrator&#60;/read&#62;<br />

        <!– change to the IBM AppServer directory –>
        

1
&#60;write&#62;cd \ibm\AppServer\bin&#60;/write&#62;<br />

        

1
&#60;read&#62;AppServer\bin&#60;/read&#62;

        <!– Execute the jacl –>
        

1
&#60;write&#62;wsadmin -conntype SOAP -port 10033

                

1
-username wasadmin -password **** -f stopApplication.jacl<br />

        

1
&#60;/write&#62;

        <!– wait for the connected to process message, which will occur on the successful completion of the script –>

1
<br />

        

1
&#60;read&#62;Connected to process&#60;/read&#62;<br />

        

1
&#60;read&#62;AppServer\bin&#60;/read&#62;<br />

    

1
&#60;/telnet&#62;<br />       &#60;/target&#62;

Step 5

mix ingredients and enjoying being able to have a one click deploy to WebSphere Portal.

Appendix

For security paranoid people with time on their hands, it is possible to do this using ssh and scp. The key parts will be step 3 and step 4. In step 3 we are using folder share and the ant copy task currently. It could be done with scp. In step 4 the use of telnet could be replaced with ssh.

1 – The telnet task depends on the availability of the commons-net jar on the classpath. (click here to download commons-net).

Related posts:

  1. Setting up Oracle XE to work with IBM WebSphere Portal IWWCM
  2. HTTP Authentication in a URL
  3. OSX RDP Client

11 Responses

  1. This script (and the assembled one* in ~aj/deployE2/ ) however doesn’t handle mapping resources like databases so you wind up with a rather blank E2 and have to deploy manually. I wonder if the magical fairies could fix that…

    *Rob’s blog – bringing a bit of IKEA to your life… :)

  2. robert says:

    you’ll probably find that it works well for updates — not quite as well for first time deploys…. and that it might take a bit of work for the magical fairies to make things work the way you want :)

  3. That was an update sadly. My magical fairies are looking a little buggy. :P

    I’m not stressed about it though, but it would be good to sort it out – the initial manual install process still needs work and documentation, it doesn’t really have a good starting point at the moment.

  4. robert says:

    hmmm…

    as fun as it is to have conversations with people I’m currently working with on my blog, I think I’ll pick up this thread elsewhere… if magical fairies produce outcomes there might be a follow up entry.

  5. robert says:

    The fairies say — RTFM (read the fairy manual) — "copy the files to the exploded WAR directory". Unfortunately unzipping an ear doesn't also unzip the embedded war. so unzipping an ear file to the exploded EAR directory != to copying files to an exploded war directory. Given that the choice of work for the fairies today might be between fixing this, and doing documentation, you might get some help :) .  In additon, copying the contents of the ear over the top will almost certainly result in the IBM deployment files being overwritten, which is a bad thing, and will cause additional problems.

  6. Bloody picky fairies… What’s the difference between EAR and WAR anyway? You have one and the other gets chopped off – it’s all related.

    On the plus side, it appears to work now. Though for the life of me I can’t remember what the previous version number was so it might just be a no-op. Doing nothing is better than breaking everything though. :)

  7. Sorry to jump in a little late here, but I’m not a big fan of using Ant to execute a script. Why not cut out the middle man and just use the ws_ant tasks that come with WebSphere? Here’s a link: http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/topic/com.ibm.websphere.javadoc.doc/public_html/api/com/ibm/websphere/ant/tasks/package-summary.html

    As far as magical fairies go, you might want to check out Phurnace Deliver. It can capture the config settings of your dev environment, abstract the jdbc url, db host, etc, and then push out to qa and prod. That would help you install the EAR file and configure the WAS container without writing Jacl/Jython/Ant scripts.

    Robert

  8. Rob says:

    Robert,

    Thanks for your comments. I agree with the sentiments regarding ANT. The reason for its usage in this particular situation is that it matches the existing infrastrutcture. In particular (as mentioned in the article) I needed a solution which would let me develop on a mac, which historically (I may be wrong in the current enviornment) hasn’t had the ability to run ws_ant.

    I’ll keep an eye out on Phurnace Deliver, and your suite of offerings. There might be some value in the future for us.

  9. Hello Guys,
    I am not sure what would be the difference using Ant and WS_Ant tasks? is in a both will use the build file to do all the work? if it is then I need to know if it will deploy everytime you update your work space. Also how can you bind with Virtual Host instead of default binding. I am very new to this. So I need as much as help I can to hone my knowledge.

  10. Rob says:

    ant and ws_ant will both use build.xml files. ws_ant is a custom IBM version of ant that includes a series of tasks specific to the IBM WebSphere environment. To see more about ws_ant, see http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/tovr_ant.html

    for more about Jacl see:
    http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.nd.multiplatform.doc/info/ae/ae/cxml_jacl.html

    The infocenter is a good spot to develop your knowledge.

  11. Private Servers says:

    Habbo Retros…

    Habbo Retros are slowly attracting more users with each passing day, most people prefer to play Habbo Retros with pets according to a recent google study, further evidence also supports that Habbo Retros have lead to an annual decrease in revenue for s…

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© Rob@Rojotek