We can have different JEE applications to install on IBM WebSphere Application Server such as:
- Enterprise applications .ear files
- Web Applications .war files
- Business Application
- Utility/shared libraries .jar files
You need to know what type of application you wish to deploy. Where to install it in the Cell. If it is an EJB application you need to provide the binding details as an initial parameter.
All application-related functions are available with AdminApp object. For making the application changes permanent you need to save the AdminConfig.
Let's see the war file installation process
AdminApp.install(ear, '[-BindJndiForEJBBusiness [[ejb_1.jar ejb1 ejb_1.jar,META-INF/ejb-jar.xml test.ejb1 jndi1 ]]]')
# For Web application inside .ear files you need to provide virtual host name. These virtual host varies in the ND cell.
AdminApp.install('fullpath/yourApp.ear', ['-MapWebModToVH', [['.*', '.*', 'default_host']]])
AdminConfig.save()
A menu driven Jython script for wsadmin
#================================================================
#
# Script Name : Deployment.py
# Created Date: 17 Oct 2015
# Developed by: Pavan Devarakonda
#
#================================================================
def cls(): print '\n'*45
def linedesign(): print '@'*50
def menu():
linedesign()
print """Deployment options
1. Show deployed Apps
2. Install App
3. Uninstall App
4. Exit
"""
linedesign()
ch=input("Please enter your choice: ")
return ch
def main():
""" Main program logic starts here """
while 1:
ch=menu()
if ch == 1:
cls(); linedesign()
print "The list of application deployed on the Cell"
print AdminApp.list()
linedesign()
elif ch == 2:
print "You selected to deploy application"
appPath=raw_input("Enter application path: ")
appName=raw_input("Enter application name: ")
AdminApp.install( appPath, ['-appname',appName , '-MapWebModToVH', [['.*', '.*', 'default_host']]])
AdminConfig.save()
elif ch == 3:
linedesign()
print "Uninstall which application?"; appName=raw_input("Application name: ")
AdminApp.uninstall(appName)
AdminConfig.save()
print "Uninstallation completed...."
else:
print "Exiting from the script...."
#sys.exit(0)
break
main()
Its execution as follows:
Check the defalthost port number mapping on the admin console.
execfile('/home/vagrant/scripts/Deployment.py')
Deployment script execution output
|
Install Web application on WebSphere server |
|
Application Status after installing |
|
Uninstall web application using Jython |
|
Web application access successful this concludes Jython script working fine |
WebSphere Admins please write your comments how to make more generic script which could deploy to cluster as well.
- Deploy EJB, WebService applications
- Target to selected cluster or app-server
- Clearing cache for web application
- App server restart if required
Thank you, excellent simple script works.
ReplyDeletethanks for the article, I want to automate the configuration related to the app deployment (queues and shared libraries jars). do you have any idea how to accomplish that?
ReplyDeleteplease provide me python script for deploying the war file in WebSphere using jenkins (taking the backup of existing war file and deploying the latest war file)
ReplyDelete