• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Jython Code Error

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Team,
I wrote a script to stop the cluster in WebSphere Application Server. While running the script i'm getting the below error. Could you please check and advise.

WASX7017E: Exception received while running file "stopCluster.py"; exception information: com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
File "<string>", line 71, in ?
NameError: arg1

SCRIPT:

# This program may be used, executed, copied, modified and distributed
# without royalty for the purpose of developing, using, marketing, or distribution
#
#-----------------------------------------------------------------
# Global stopCluster
#-----------------------------------------------------------------
#
# The purpose of this example is to demonstrate the invocation
# of stopping a cluster passing args through a shell script.
#
# This script can be included in the wsadmin command invocation like this:
#
# ./wsadmin -lang jython -f stopCluster.py clusterName cell
#
# Simply create a shell script with the following
# #!/bin/sh
# # Change the directory to your WAS_HOME/bin
# cd /opt/websphere/bin
# # issue the wsadmin command with the two arguments
# # make sure your path to stopCluster.py is correct
# # in the example below it is located in WAS_HOME/bin
# # clusterName below = your cluster name found via the admin console
# # cell below = your cell name found via the admin console
# ./wsadmin.sh -lang jython stopCluster.py clusterName cell
#
# The script expects one parameter:
# arg1 - cluster Name
# arg2 - cell Name
#
#-----------------------------------------------------------------
#
import sys
import string
import random

def x(arg1,cel):


#--------------------------------------------------------------
# set up globals
#--------------------------------------------------------------
global AdminControl
global AdminConfig
global AdminTask
global AdminApp
global Help

#---------------------------------------------------------
# First, list the existing cluster(s)
#---------------------------------------------------------
cluster = AdminConfig.list('ServerCluster')
print "----------------------------------------------------------"
print "Clusters found: "
print cluster
print "----------------------------------------------------------"


#---------------------------------------------------------
# Second, get the cell information
#---------------------------------------------------------
printcellname = AdminConfig.list('Cell')
print "----------------------------------------------------------"
print "Cell(s): "
print printcellname
print "----------------------------------------------------------"


#---------------------------------------------------------
# Here is the cluster we'll be dealing with...
#---------------------------------------------------------
work=arg1
print "----------------------------------------------------------"
print "The cluster we are going to perform action STOP on:"
print work
print "----------------------------------------------------------"

#---------------------------------------------------------
# Here is the cell we'll be dealing with...
#---------------------------------------------------------
cwork = cel
print "----------------------------------------------------------"
print "The cell we are working with:"
print cwork
print "----------------------------------------------------------"

#---------------------------------------------------------
# Creating the stopcluster variable
#---------------------------------------------------------
stopcluster = AdminControl.completeObjectName('cell='+cwork +',type=Cluster,name='+ work +',*')
#---------------------------------------------------------
print "----------------------------------------------------------"
print "Successfully completed the object name and the cluster that will stop is:"
print stopcluster
print "----------------------------------------------------------"

#---------------------------------------------------------
# A very simple stop command
# to run start cluster simply change below command to
# AdminControl.invoke(stopcluster, 'start')
#---------------------------------------------------------
print "----------------------------------------------------------"
print "A simple stop command....."
print AdminControl.invoke(stopcluster, 'stop')
message = "Tail the app server logs to confirm they have stopped"
print message
print "----------------------------------------------------------"


#-----------------------------------------------------------------
# Main
#-----------------------------------------------------------------
if len(sys.argv) != 2:
print "x: this script requires 2 parameters:"
print " cluster name, and cell name"
print ""
print "e.g.: wsadmin -lang jython -f stopCluster.py REMCluster u060rem11Network"
else:
x(sys.argv[0], sys.argv[1])


Thanks a lot in advance.

Regards,

Srikanth V

reply
    Bookmark Topic Watch Topic
  • New Topic