Date Created: Thu 07-Feb-2008

Related Document Categories:


    Using JACL to start a WebSphere Application.

    This script is designed to work with WebSphere ND and starts an application in a names cluster in a given cell.

    start_application.jacl

    #------------------------------------------------------------------------------------------
    # This script starts application installed on cluster.
    # Pass application name, cluster name and cell name as command line argument to this script in the given sequence.
    # Usage: wsadmin.sh -f ccs_start_application.jacl applicationName clusterName cellName
    #------------------------------------------------------------------------------------------

    if {$argc == 3} {
    #set appname [$props getProperty ear.name]
    #set clusterName [$props getProperty sib.cluster.name]
    #set cell [$ccs_props getProperty was_cell]

    set appname [lindex $argv 0]
    set clusterName [lindex $argv 1]
    set cell [lindex $argv 2]

    set clusterId [$AdminConfig getid /ServerCluster:$clusterName/]
    if {[llength $clusterId] == 1} {
    puts "Cluster '$clusterName' exists."
    set clusterMembers [$AdminConfig list ClusterMember $clusterId]
    set installedApps [$AdminApp list]

    # Check if application is installed
    set applicationFound 0

    foreach appId $installedApps {
    set existingApp $appId
    if {[string compare $appname $existingApp] == 0} {
    set applicationFound 1
    break
    }
    }

    if {$applicationFound == 1} {
    puts "Application $appname on cluster $clusterName found."
    # Start the application if it is installed
    puts "-------------------------"
    puts "Starting the application: $appname on cluster $clusterName"
    puts "-------------------------"
    foreach m_id $clusterMembers {
    set currentServer [$AdminConfig showAttribute $m_id memberName]
    set currentNodeName [$AdminConfig showAttribute $m_id nodeName]
    set query cell=$cell,node=$currentNodeName,type=ApplicationManager,process=$currentServer,*
    set appManager [$AdminControl queryNames $query]
    puts "Starting $appname on node $currentNodeName, server $currentServer."
    $AdminControl invoke $appManager startApplication $appname
    }
    } else {
    puts "-------------------------"
    puts "Application: $appname on cluster $clusterName not found"
    puts "-------------------------"
    }
    } else {
    puts "Cluster '$clusterName' doesnot exist."
    }
    } else {
    puts "Please supply application name, cluster name and cell name as command line argument."
    puts "Usage: wsadmin.sh -f ccs_start_application.jacl applicationName clusterName cellName"
    }

Middleware Mentor - Steven Charles Robinson

About Me

Steve Robinson has been working in IT for over 15 years and has provided solutions for many large-enterprise corporate companies across the world. Steve specialises in Java and Middleware consulting. Steve comes from both an administration and development background.

Before moving to JEE, Steve was an accomplished developer and consultant for both IBM Lotus Notes and Microsoft .NET Technologies.

Follow Steve as @stevencrobinson on twitter.

Read my books?

IBM WebSphere Application Server 8.0 Administration Guide

IBM WebSphere Application Server 8.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Categories

Oracle WebLogic Categories

JBoss Categories

Other Categories