Hi,
If we have many Application, all of them should be deployed to WebLogic Server then It’s very unconvenient to deploy these Applications using Admin Console one by one.
Here we have a Simplest WLST script developed by “Ms. Tasleem Shaikh”, which is able to do this combersome job for us by a Single Enter Key Press…
Step1). First of all Place all the Applications in a perticular Directory:
Example: C:DELETEWLST_Deploy_Test
I have placed three Applications inside this Directory:
1). “Web5” Which is an Exploded WebApplication
2). “SessionTest.war” Which is An Archived WebApplication
3). “ejb20_basic_statelessSession.jar” is an Archived StatelessSession Bean 2.x Appication
Step2). Now Create a Text File “applicationsList.txt” (File Name may be any thing) which should contain All the Deployable File/Folder names like below:
“applicationsList.txt”
————————–
Web5
SessionTest.war
ejb20_basic_statelessSession.jar
————————–
Step3). Now run the following WLST script to deploy all these applications one by one on WebLogic Server.
“deployRecursively.py”
connect('weblogic','weblogic','t3://localhost:7001') target='AdminServer' f = open(r'./applicationsList.txt','r') #In Above line you can specify the Complete Path of the “applications.txt” as well print f for i in range(3): line=f.readline() line1=line[:-1] appName='./'+line1 print '*****************'+appName edit() startEdit() deploy(appName=line1,path=appName, targets=target) save() activate() f.close()
Step 4). Now open a command Window and run either “setWLSEnv.cmd” or “setDomainEnv.cmd” then then type the following comand to run the “deployRecursively.py” script:
C:DELETEWLST_Deploy_Test> java weblogic.WLST deployRecursively.py
NOTE A): In the Above script the
for i in range(3) <——- here range(3) indicates that we are going to deploy Three Applications.
NOTE B): In place of the following relative path :
f = open(r’./applicationsList.txt’,’r’)
you can specify the Absolute path of “applicationsList” as well.
NOTE C): If you want to deploy your Application to a Cluster then Specify the target name as the Cluster Name.
target=’AdminServer’ (To Deploy Applications to AdminServer Only)
target=’ClusterA’ (To Deploy Applications to ClusterA Only)
Special Thanks to “Ms. Tasleem Shaikh” for developing this Great TimeSaving WLST Script.
December 8th, 2009 on 8:23 am
Thanks Jay, for putting the script on the blog. I am sure most of the people who are fed up with deploying the applications one by one from admin console, will be happy to get a script like this.
January 19th, 2010 on 11:37 am
THanks … and what to modify if we want any specific application to deployed as a Library instead of an application?
January 19th, 2010 on 12:21 pm
Hi Subhasish,
Please don’t provide Library Specific Informations inside the “EAR/META-INF/MANIFEST>MF” File…And In the Above WLST script replace the deploy command by Following:
deploy(appName=line1,path=appName, targets=target, libraryModule=’true’, libImplVersion=’1.1′, libSpecVersion=’1.2′)
For detailed Informations Please refer to : http://download-llnw.oracle.com/docs/cd/E13222_01/wls/docs92/config_scripting/reference.html#wp1024285
Keep Posting 🙂
Thanks
Jay SenSharma
May 7th, 2010 on 8:50 am
If i want to undeploy the same application, can i just use the same script and just modify the line – deploy(appName=line1,path=appName, targets=target) to
undeploy(appName=line1,path=appName, targets=target)?
May 28th, 2010 on 8:10 am
Hi ,
I want to check the status of application deployed on managed server.
Application is running but on console i see state as Prepared.
Thanks in advance
May 28th, 2010 on 11:46 am
Hi,
I have seen similar issues in WebLogic Portal Domains. Specially in case of Shared Libraries. But not in WLS.
While deploying your Applications on the server did u see any warning? Exactly at the time of deployment.
Which version of WLS are u using?
Are u using any Shared Libraries in your Application?
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
June 2nd, 2010 on 3:32 pm
Under what situations, does the deployment of an application compels a weblogic server restart?
Under what situation, it does not require a weblogic server restart?
June 3rd, 2010 on 10:21 am
Hi Shaikh,
Usually there should be no server restart needed if we deploy s Normal J2EE applications on webLogic Server. But in some cases i have seen that restart is needed specially in case of some MDB applications and some JTA based applications because weblogic writes some TLOG files and some FileStores which gets currupted and causes redeployment issues. So in those cases we need to shutdown the servers and then after cleaning the TLOGs and FileStores…Caches we need to restart the Servers. But still remember that Those are special scenarios not the Normal scenariops.
Apart from this …Many times we Put some application specific Jars and properties files in server Classpath Whhich is not good. (Which is not standard practice) … because if we need to make any changes on those Jars/Properties files then we need to restart the Servers sothat the Applications will be able to Pick the Changes.
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
September 20th, 2010 on 3:52 am
Hi Jay,
Can you explain me how to deploy the apps using the admin console such tat if there are 3 apps (like app A, app B, app C)to be deployed and i want App C to be deployed 1st before app A,B. Explain me in detail…
Thanks
September 20th, 2010 on 9:34 am
Hi Yadav,
Admin Console doesnt allow you tio set the Preference of the application deployment …at the time of Deployment. So the order will be same in which you are deploying your Applications on the Server.
But Once the Application is deployed on the Server you can set the Deployment Order for your Applications sothat from next time onwards as soon as the Server will be bounced then the Applications will be activated in the same deployment Order. Please refer to : http://download.oracle.com/docs/cd/E14571_01/apirefs.1111/e13952/taskhelp/deployment/ChangeTheServerDeploymentOrder.html for more detailed informations on Deployment Order.
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
December 7th, 2010 on 8:33 am
Hi friends ,
I have some basic questions in automating the deployments ( war / ear / jar ) . Let me explain the set up .
Weblogic version : 9.2 & 10
servers : Unix Sun Solaris 10
We have 2 production servers ( PRUXAP01 , PRUX Ap02 ) which are running in Unix Solaris platform . We have 2 domains ( EMC , EMCSB )created across these servers in total we have 10 manage servers scross these 2 physical boxes .
– We frequently get application deployment requests ( mostly ear / war files ) to deploy on the console . It takes time to deploy and all the time I dont want to use the manual process of deploying it by logging in the console .
– I want to automate these deployments , I heard there are many tools which can be used to Automate the regular deployments .
– Please suggest me how can i do that and How do i procced further in these automation .
– I heard abour WLST & Hudson tool but not sure how do i incorpate my setup with these tools .
All the advices are welcome.
Please contact me @ kieruns@gmail.com
thanks,
Kiran
December 7th, 2010 on 10:44 am
Hi Kiran,
Welcome to Middleware Magic.
You can solve your issue by using the above python script given in the post and just replacing the target.
Also Jay has given few more links in the OTN link below which might also help you.
http://forums.oracle.com/forums/message.jspa?messageID=9182376#9182376
Hope your issue would gets resolved.
Regards,
Ravish Mody
December 14th, 2010 on 10:24 am
Hi team ,
I tried exactly as specified in the script i get these syntax errors As mentioned below :
C:OFM_TESTuser_projectsdomainsbase_domain>
C:OFM_TESTuser_projectsdomainsbase_domain>java weblogic.WLST
Initializing WebLogic Scripting Tool (WLST) …
Welcome to WebLogic Server Administration Scripting Shell
Type help() for help on available commands
wls:/offline> execfile(‘C:DELETEWLST_Deploy_TestdeployRecursively.py’)
Traceback (innermost last):
File “”, line 1, in ?
File “C:DELETEWLST_Deploy_TestdeployRecursively.py”, line 1
ùùùùùùùùû
^
SyntaxError: Lexical error at line 1, column 1. Encountered: “u2014” (8212), a
fter : “”
wls:/offline>
It indicates some lexical error but not able to figure out .
Any suggestions please :
thanks,
Kiran
December 14th, 2010 on 11:02 am
Hi Kiran,
Try using the below command
The only difference in the above command is that I have added a small “r” at the starting. The reason for using it is because as by default WLST only takes forward slash “/”. So if you are not comfortable using the “r” then use the forward slash instead of back slash
Hope this will solve your issue.
Regards,
Ravish Mody
December 14th, 2010 on 11:48 am
Hi Ravish ,
thanks for the update but even after using the command as you suggested i still get the error
execfile(‘C:/DELETE/WLST_Deploy_Test/deployRecursively.py’)
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
H:Kiran.Sreerangam>c:
C:>cd C:OFM_TESTuser_projectsdomainsbase_domainbin
C:OFM_TESTuser_projectsdomainsbase_domainbin>setDomainEnv.cmd
C:OFM_TESTuser_projectsdomainsbase_domain>java weblogic.WLST
Initializing WebLogic Scripting Tool (WLST) …
Welcome to WebLogic Server Administration Scripting Shell
Type help() for help on available commands
wls:/offline>
wls:/offline> execfile(r’C:DELETEWLST_Deploy_TestdeployRecursively.py’)
Traceback (innermost last):
File “”, line 1, in ?
File “C:DELETEWLST_Deploy_TestdeployRecursively.py”, line 1
ùùùùùùùùû
^
SyntaxError: Lexical error at line 1, column 1. Encountered: “u2014” (8212), a
fter : “”
wls:/offline> execfile(‘C:/DELETE/WLST_Deploy_Test/deployRecursively.py’)
Traceback (innermost last):
File “”, line 1, in ?
File “C:/DELETE/WLST_Deploy_Test/deployRecursively.py”, line 1
ùùùùùùùùû
^
SyntaxError: Lexical error at line 1, column 1. Encountered: “u2014” (8212), a
fter : “”
wls:/offline>
I tried using fwd slash aswell as backward slash still the same yntax error .
December 14th, 2010 on 12:08 pm
Hi Kiran,
I have updated the Script …It was earlier having some special Unicode Characters inside it (Example ` is replaced with ‘ )
You can again copy and paste same WLST script …and Now it should work fine. http://middlewaremagic.com/weblogic/?p=303
NOTE: Just select the Single Quote Characters in your Script File and Replace All it with the Single Quote typed by your Keyboard.
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
December 14th, 2010 on 12:14 pm
Hi Kiran,
You can see the Special Characters inside Plain Non Unicode Editors…
You can see these Special Characters in Wiodows Editor as well…. Just try the following command in a Fresh Command Prompt:
edit C:DELETEWLST_Deploy_TestdeployRecursively.py
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
December 14th, 2010 on 12:28 pm
Hi JAy ,
here problem is First line itself it gives me the syntax error which shows the command
execfile(‘C:/DELETE/WLST_Deploy_Test/deployRecursively.py’)
itself it throws the erro it doesnt even go inside the .py file .
Still i tried as suggested by you still the same error .
thanks,
Kiran
December 14th, 2010 on 1:07 pm
Hi Kiran,
Please do the following:
Step1). Copy the Below Script and then as it is:
Step2). Now execute the following line :
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
December 14th, 2010 on 2:10 pm
Hi Jay .
sorry for troubling u still i am getting errors
”
wls:/offline> connect(‘weblogic’,’F1formula’,’t3://localhost:7001′)
Connecting to t3://localhost:7001 with userid weblogic …
Successfully connected to Admin Server ‘AdminServer’ that belongs to domain ‘bas
e_domain’.
Warning: An insecure protocol was used to connect to the
server. To ensure on-the-wire security, the SSL port or
Admin port should be used instead.
wls:/base_domain/serverConfig>
wls:/base_domain/serverConfig> target=’AdminServer’
wls:/base_domain/serverConfig>
wls:/base_domain/serverConfig>
wls:/base_domain/serverConfig>
wls:/base_domain/serverConfig> f = open(r’./C:/DELETE/WLST_Deploy_Test/applicat
ionsList.txt’,’r’)
Traceback (innermost last):
File “”, line 1, in ?
IOError: No such file or directory: ./C:/DELETE/WLST_Deploy_Test/applicationsLis
t.txt
wls:/base_domain/serverConfig>
wls:/base_domain/serverConfig> #In Above line you can specify the Complete Path
of the “applications.txt” as well
wls:/base_domain/serverConfig>
wls:/base_domain/serverConfig>
wls:/base_domain/serverConfig>
wls:/base_domain/serverConfig> print f
Traceback (innermost last):
File “”, line 1, in ?
NameError: f
wls:/base_domain/serverConfig>
wls:/base_domain/serverConfig> for i in range(3):
…
Traceback (innermost last):
(no code object) at line 0
File “”, line 2
SyntaxError: invalid syntax
wls:/base_domain/serverConfig> line=f.readline()
Traceback (innermost last):
File “”, line 1, in ?
NameError: f
wls:/base_domain/serverConfig>
wls:/base_domain/serverConfig> line1=line[:-1]
Traceback (innermost last):
File “”, line 1, in ?
NameError: line
wls:/base_domain/serverConfig>
wls:/base_domain/serverConfig> appName=’./’+line1
Traceback (innermost last):
File “”, line 1, in ?
NameError: line1
wls:/base_domain/serverConfig>
wls:/base_domain/serverConfig> print ‘*****************’+appName
Traceback (innermost last):
File “”, line 1, in ?
NameError: appName
wls:/base_domain/serverConfig>
wls:/base_domain/serverConfig> edit()
Location changed to edit tree. This is a writable tree with
DomainMBean as the root. To make changes you will need to start
an edit session via startEdit().
For more help, use help(edit)
wls:/base_domain/edit>
wls:/base_domain/edit> startEdit()
Starting an edit session …
Started edit session, please be sure to save and activate your
changes once you are done.
wls:/base_domain/edit !>
wls:/base_domain/edit !> deploy(appName=line1,path=appName, targets=target)
Traceback (innermost last):
File “”, line 1, in ?
NameError: line1
wls:/base_domain/edit !>
wls:/base_domain/edit !> save()
Saving all your changes …
Saved all your changes successfully.
wls:/base_domain/edit !>
wls:/base_domain/edit !> activate()
Activating all your changes, this may take a while …
The edit lock associated with this edit session is released
once the activation is completed.
Activation completed
wls:/base_domain/edit>
wls:/base_domain/edit> f.close()
Traceback (innermost last):
File “”, line 1, in ?
NameError: f
wls:/base_domain/edit> execfile(‘C:/DELETE/WLST_Deploy_Test/deployRecursively.py
‘)
Traceback (innermost last):
File “”, line 1, in ?
File “C:/DELETE/WLST_Deploy_Test/deployRecursively.py”, line 1
ùùùùùùùùû
^
SyntaxError: Lexical error at line 1, column 1. Encountered: “u2014” (8212), a
fter : “”
wls:/base_domain/edit>
thanks,
Kiran
December 15th, 2010 on 8:21 am
Hi Jay ,
I edited using the editor and removed the speacil characters and executed it now i get a different error .
Initializing WebLogic Scripting Tool (WLST) …
Welcome to WebLogic Server Administration Scripting Shell
Type help() for help on available commands
wls:/offline> execfile(‘C:/DELETE/WLST_Deploy_Test/deployRecursively.py’)
Traceback (innermost last):
File “”, line 1, in ?
File “C:/DELETE/WLST_Deploy_Test/deployRecursively.py”, line 9
line=f.readline()
^
SyntaxError: invalid syntax
wls:/offline>
I am pasting the exact script which i am trying to use ::
connect(‘weblogic’,’F1formula’,’t3://localhost:7001′)
target=’AdminServer’
f = open(r’./C:/DELETE/WLST_Deploy_Test/applicationsList.txt’,’r’)
#In Above line you can specify the Complete Path of the “applications.txt” as well
print f
for i in range(3):
line=f.readline()
line1=line[:-1]
appName=’./’+line1
print ‘*****************’+appName
edit()
startEdit()
deploy(appName=line1,path=appName, targets=target)
save()
activate()
f.close()
please help me out in running this one .
Else please suggest which tool i can use for auto deployments .
thanks,
Kiran
December 15th, 2010 on 9:24 pm
Hi Kiran,
Why dont you try to run the script in simple way:
1). open a command prompt.
2). run the “setWLSEnv.cmd”
3). cd C:DELETEWLST_Deploy_Test
4). java weblogic.WLST C:/DELETE/WLST_Deploy_Test/deployRecursively.py
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
December 15th, 2010 on 9:30 am
HI Jay ,
I tried deploying using weblogic deployer and i used the commands as given by you i get the message ” no source specified for operation ” even after specifying the source .I tried weblogic deployer as WLST is giving me syntax errors .
Here is the printscreen of mysystem .
C:>cd C:OFM_TESTuser_projectsdomainsbase_domainbin
C:OFM_TESTuser_projectsdomainsbase_domainbin>setDomainEnv.cmd
C:OFM_TESTuser_projectsdomainsbase_domain>java weblogic.Deployer http://loca
lhost:7001 weblogic F1formula -deploy advisories-presentation-ear-01-DEC-2010 C:
/DELETE/WLST_Deploy_Test/advisories-presentation-ear-01-DEC-2010.ear Test_Manage
dServer1,Test_ManagedServer2
weblogic.Deployer invoked with options: http://localhost:7001 weblogic F1formul
a -deploy advisories-presentation-ear-01-DEC-2010 C:/DELETE/WLST_Deploy_Test/adv
isories-presentation-ear-01-DEC-2010.ear Test_ManagedServer1,Test_ManagedServer2
No source specified for operation
C:OFM_TESTuser_projectsdomainsbase_domain>java weblogic.Deployer http://loca
lhost:7001 weblogic F1formula -deploy advisories-presentation-ear-01-DEC-2010 Te
st_ManagedServer1,Test_ManagedServer2 C:/DELETE/WLST_Deploy_Test/advisories-pres
entation-ear-01-DEC-2010.ear
weblogic.Deployer invoked with options: http://localhost:7001 weblogic F1formul
a -deploy advisories-presentation-ear-01-DEC-2010 Test_ManagedServer1,Test_Manag
edServer2 C:/DELETE/WLST_Deploy_Test/advisories-presentation-ear-01-DEC-2010.ear
No source specified for operation
Not sure what exactly its trying to check even after specifying source .
Please help me out .
thanks,
Kiran
December 15th, 2010 on 9:18 pm
Hi Kiran,
Plese try the below command to deploy your application:
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
December 16th, 2010 on 7:44 am
hI JAY ,
THANKS FOR THE UPDATE
December 16th, 2010 on 7:46 am
Hi jay .
I am able to deploy using Weblogic.Deployer but WLST is still giving me syntax errors .
C:OFM_TESTuser_projectsdomainsbase_domainbin>setDomainEnv.cmd
C:OFM_TESTuser_projectsdomainsbase_domain>cd C:DELETEWLST_Deploy_Test
C:DELETEWLST_Deploy_Test>java weblogic.WLST C:/DELETE/WLST_Deploy_Test/deployR
ecursively.py
Initializing WebLogic Scripting Tool (WLST) …
Welcome to WebLogic Server Administration Scripting Shell
Type help() for help on available commands
Problem invoking WLST – Traceback (innermost last):
(no code object) at line 0
File “C:DELETEWLST_Deploy_TestdeployRecursively.py”, line 9
line=f.readline()
^
SyntaxError: invalid syntax
Dont kow how to fix this .
thanks,
Kiran
December 16th, 2010 on 11:13 am
Hi Kiran,
WLST Script is very sensitive to the Alignment and Indentations so Plese donot Ignore the Spaces which are there at the Beginning of any line…because those are acually the Opening and termination of For Loop. Please refer to the steps mentioned in the following comment: http://middlewaremagic.com/weblogic/?p=303#comment-2265
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
December 16th, 2010 on 11:17 am
Hi Kiran,
WLST Script is very sensitive to the Alignment and Indentations so Please donot Ignore the Spaces which are there at the Beginning of any line…because those are acually the Opening and termination of For Loop. So please copy and paste the WLST Script carefully
Please refer to the steps mentioned in the following comment: http://middlewaremagic.com/weblogic/?p=303#comment-2265
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
February 5th, 2011 on 6:58 am
Hi jay,what is the python editor your using to write WLST scrips..
February 5th, 2011 on 10:34 am
Hi Venkatesh,
We just test WLST commands in interactive mode …”java weblogic.WLST” command opens the WLST editor in interactive mode. So first we try a sequence of commands there …once we see that the commands are working fine then we associate the Commands inside a Script.
.
.
Thanks
Jay SenSharma
March 22nd, 2011 on 10:50 am
Hi All,
I am doing one deployment using WLST deploy command passing appName,path and targets as arguments :-
deploy(appName=’someName’,path=’Somepath/some.war’ , targets=’AdminServer’)
I am executing this command like
/some_path/bea/wls92mp2/weblogic92/server/bin/setWLSEnv.sh from some directory
and then starting WLST and running this command
Command is working fine but it is creating a directory structure from the path where i am giving the command
PATH_FROM_WHERE_COMMAND_IS_EXECUTED/config/deployments/some.war/
some.war is the empty directory with same name of war file which i deployed.
I am bit new to wlst and can somebody help to tell its impact and how to get rid of it….thanks…
I am using solaris, weblogic 9.2..
The issue is happening even if i am using interactive mode..
March 22nd, 2011 on 11:43 am
Hi ms471j,
It seems that is normal and till now we have not come across any issue with it, however if you see any negative impact do let us know.
Regards,
Ravish Mody
March 22nd, 2011 on 1:19 pm
Ravish, thanks for such a fast response..Well just to clarify, everytime we use deploy command it will create directory structure like this?..Is this a usual behaviour?…What if i delete it after deploying
Regards,
Manish
March 22nd, 2011 on 1:29 pm
Hi ms471j,
I looks as its a default behaviour and as explained before we do not see any negative impact, does not take more memory so we never tried to debug it. However if you are keen to know why is this happening, is it safe to delete the folder etc, then would suggest you to open an ticket with Oracle Weblogic Support team and they would let you know if they have come across any issues with this behaviour and do share it with us also.
Regards,
Ravish Mody
May 12th, 2011 on 9:54 am
Hi,
Can you please show an example of deploying an ear with whose web application context is targeted to a virtual host and the rest of the ejb modules mapped to the cluster members using WLST ?
I tried using the record option to generate a script from the console for the same but unfortunately that didn’t help.
Thanks in advance.
Regards,
Kiran
November 10th, 2011 on 4:15 am
Jay/Ravish,
I need a WLST automation deployment script which need to do the following things.
1) We should use the same deployment scripts calling the Environment variable.
like DEV, TEST, UAT, PROD
It should pick the Environment and deploy the application related to that environment.
The below script is doing deployment and also restarting the managed servers after the deployment is done. Let me know if any modifications need to be done. or any other script you can provide me.
It’s little urgent …
#The Deployment Script
# * Connects WLST to the Admininstration server
from java.util import *
from javax.management import *
import javax.management.Attribute
#############################################################################################################
# Step: 1 –> Starting the WLST Online in Scripting Mode.
#
# Script will be connecting to WEBLOGIC APPLICATION SERVER
############################################################################################################
print ‘Starting the Script……………’
import time
time.sleep(1)
username = ‘weblogic’
password = ‘O0gf1sh1’
clusters = ‘IDMAdminServer’
url = ‘t3://dappam05.cap.org:7001’
connect(weblogic,O0gf1sh1,t3://dappam05.comsys.org:7001)
print connected
print ‘ ——>> SCRIPT CONNECTED TO ADMINISTRATION SERVER…………………….’
#############################################################################################################
# Step: 2 –> Stopping the Deployed Application.
############################################################################################################
progress=stopApplication(‘MYAPP’)
import time
time.sleep(5)
progress=stopApplication(‘MYResourceAdapter’)
import time
time.sleep(5)
print ‘ ——>> APPLICATION IS STOPPED –>> PLEASE CHECK STOP STATUS……………….
‘#############################################################################################################
# Step: 3 –> Undeploying the Application from Administartion Console.
############################################################################################################
clustHM = HashMap()
edit()
startEdit()
undeploy(‘MYAPP’)
print progress.printStatus()
undeploy(‘MYResourceAdapter’)
print progress.printStatus()
import time
print ‘ ——>> APPLICATION IS UNDEPLOYED –>> PLEASE CHECK STATUS…………………………..’
time.sleep(5)
save()
activate(block=”true”)
print progress.printStatus()
#############################################################################################################
# Step: 4 –> Shutting Down all the servers in the Cluster.
############################################################################################################
shutdown(‘wls_oamCluster’,’Cluster’)
import time
time.sleep(10)
state(‘DevCluster’,’Cluster’)
print progress.printStatus()
import time
time.sleep(5)
print ‘ ——>> SHUT-DOWN –>> PLEASE CHECK SERVER LOGS FOR COMPLETE SHUTDOWN…………………..’
disconnect()
print ‘—————————Disconnecting From Administration Server—————————-‘
#############################################################################################################
# Step: 6 –> Starting the Managed Servers in the Cluster without Nodemanager.
############################################################################################################
# To Start the Managed Server Re-Connect to WLST to do So.
print ‘Starting the Script……………’
domainDirectory = ‘/opt/ora/idmdev/Middleware/user_projects/domains/IDMDevdomain’
managedServerName = (‘wls_oam1’, ‘wls_oam2’)
adminUrl = ‘t3://dappam05.comsys.org:7001’
username = ‘weblogic’
password = ‘O0gf1sh1’
clusters = ‘wls_oamClusterr’
connect(weblogic,O0gf1sh1, t3://dappam05.comsys.org:7001)
print connected
print ‘ ——>> STARTING ALL THE MANAGED_APP_SERVERS IN CLUSTER –>> PLEASE CHECK SERVERLOGS FOR ERRORS……….’
try:
svrOutLoc = domainDirectory+”/servers/”managedServerName”/logs/”managedServerName”_”+”.out”
print domainDirectory+”/bin/startManagedWebLogic.sh “managedServerName” “adminUrl” > “svrOutLoc” 2>&1 &n”
import os
os._shellEnv.system(domainDirectory+”/bin/startManagedWebLogic.sh “managedServerName” “adminUrl” > “svrOutLoc” 2>&1 &n”)
except Exception,e:
e.printStackTrace()
raise “Error starting the weblogic server “+managedServerName
import time
time.sleep(140)
disconnect()
print ‘ ——>> MANAGED_APP_SERVERS STARTED SUCCESSFULLY –>> PLEASE CHECK SERVERLOGS FOR ERRORS…………….’
#############################################################################################################
# Step: 7 –> Deploying the Application from Administartion Console.
############################################################################################################
print ‘Starting the Script……………’
import time
time.sleep(1)
username = ‘weblogic’
password = ‘O0gf1sh1’
clusters = ‘wls_oamCluster’
url = ‘t3://dappam05.comsys.org:8001’
connect(username,password,url)
print connected
clustHM = HashMap()
edit()
startEdit()
import time
time.sleep(1)
print ‘ ——>> DEPLOYING THE APPLICATION TO PRODUCTIONCLUSTER –>> PLEASE CHECK SERVERLOGS FOR ERRORS…….’
progress=deploy(‘MYAPP’,’/usr/local/appstage/applications/MYAPP’,’ProductionCluster’)
progress=deploy(‘MyResourceAdapter’,’/usr/local/appstage/applications/MyResourceAdapter.rar’,’ProductionCluster’)
print progress.printStatus()
import time
time.sleep(5)
print progress.getState()
‘completed’
save()
activate(block=”true”)
progress=startApplication(‘MYAPP’)
progress=startApplication(‘MYResourceAdapter’)
print progress.getState()
disconnect()
print ‘—————————————————————————————————————‘
print ‘**********************DEPLOYMENT COMPLETED SUCCESSFULLY********************************************************’
print ‘—————————————————————————————————————‘
import time
time.sleep(5)
exit()
November 13th, 2011 on 5:10 pm
hello,
I’m using WLS10 on solaris, and used to deploy ear’s from the console application.
Now I want to use WLST script for that and my question is:
when deployed through the console application the ears were deployed and save under: /wli/user_projects/domains/stress_TS1/servers/AdminServerTS1/upload
But now when using
deploy(appName=line1,path=appName, targets=target)
in case I put the ear’s under /tmp the ear deployment path will be /tmp, how can I set it to be loaded into the original path (/wli/user_projects/domains/stress_TS1/servers/AdminServerTS1/upload) instead from /tmp.
Do I have to put the new ears in that directory instead of /tmp, but then I change the current ear with the new one before I doploy the new one.
hopw I clear with my question.
Thanks
November 13th, 2011 on 5:20 pm
Hi Lea,
The deploy() function of WLST has an attribute called as “upload” you can set that value to “true” as following:
Example:
deploy(appName=line1,path=appName, targets=target,upload=”true”)
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
November 13th, 2011 on 8:40 pm
hi Thanks,
you might know what is the problem I have, it’s a long description 🙂
Hi,
I’m running the following script, the ear installed succesfully and I can see it in the console application.
The script
==========
connect(‘weblogic’,’weblogic’,’t3://wli10stress-app:6001′)
edit()
startEdit()
file = open(‘/tmp/deploy_ear/earList.txt’)
lines = file.readlines()
target=’AdminServerTS1′
deploy_path=’/tmp/deploy_ear/’
#ear_path=’/wli/user_projects/domains/stress_TS1/servers/AdminServerTS1/upload/’
for line in lines:
ear_name = line.replace(‘n’,”)
deploy_name=ear_name.replace(‘.ear’,”)
deploy(appName=deploy_name,path=deploy_path+ear_name, targets=target)
#deploy(appName=ear_name,path=deploy_path+ear_name, targets=target, upload=’true’)
#deploy(appName=deploy_path+ear_name,path=ear_path+ear_name, targets=target)
save()
activate()
exit()
The script running output
=========================
Starting an edit session …
Started edit session, please be sure to save and activate your
changes once you are done.
Deploying application from /tmp/deploy_ear/MqCtrl_Ear.ear to targets AdminServerTS1 (upload=false) …
You have an edit session in progress, hence WLST will not
block for your deployment to complete.
Started the Deployment of Application. Please refer to the returned WLSTProgress object or variable LAST to track the status.
Saving all your changes …
Saved all your changes successfully.
Activating all your changes, this may take a while …
The edit lock associated with this edit session is released
once the activation is completed.
Activation completed
Exiting WebLogic Scripting Tool.
bash-3.00$
Then I doing stop to the ear from the console application, but when I try to start it it changed from Prepared –> Failed
Console error
=============
java.lang.IllegalStateException: Duplicate call to initDefaultCalculator()
Errors were encountered while performing this operation.
weblogic log error:
===================
<In webapp , the url template uses the {url:port} token. The system may not pick up the correct ports if you are using a proxy server. Consider hardcoding the ports in a production environment.>
<In webapp , the url template uses the {url:port} token. The system may not pick up the correct ports if you are using a proxy server. Consider hardcoding the ports in a production environment.>
November 13th, 2011 on 11:25 pm
Hi Lea,
I don;t see the Exception or error to check what is failing in the application. Can you post more exceptions if you see any in your log.
java.lang.IllegalStateException: Duplicate call to initDefaultCalculator()
The above error looks like is coming from your applications some ” initDefaultCalculator()” Can u please check your application if that method is present somewhere? Or if any duplicate deployment is happening for the component which is having the same method twice?
Tthe following message which you are getting in your logs are not actually error/exception rather those are Warnings (these warnings usually donot cause application deployment failure) :
[In webapp , the url template uses the {url:port} token. The system may not pick up the correct ports if you are using a proxy server. Consider hardcoding the ports in a production environment.]
Above warning can be seen while deploying your applications on the Portal/WLI server if the application contains some portal resources including beehive components. those warnings can be supressed/corrected bu putting the right values for the port in ” WEB-INF/beehive-url-template-config.xml” as mentioned in the following link:
http://download.oracle.com/docs/cd/E13155_01/wlp/docs103/portals/develop_portals.html#wp1014523
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
November 27th, 2011 on 7:50 pm
Hi Jay,
For the initDefaultCalculator() error, there is a patch that fix it: p12690642_103100_Generic.zip
Thanks
Lia
February 12th, 2013 on 8:38 am
All, do you know what is wrong with below?
file = open(‘path-to/applications.txt’)
lines = file.readlines()
target=’cluster1′
deploy_path=’path to deployments dir/’
#ear_path=./wli/user_projects/domains/stress_TS1/servers/AdminServerTS1/upload/.
for line in lines:
ear_name = line.replace(‘n’,’)
deploy_name = ear_name.replace(‘.war’,’)
deploy(appName=deploy_name,path=deploy_path+ear_name, targets=target)
save()
activate()
exit()
*** couldn’t get rid of this error.
Problem invoking WLST – Traceback (innermost last):
(no code object) at line 0
File “path-to/deploy.py”, line 44
ear_name = line.replace(‘n’,’)
^
SyntaxError: invalid syntax
i tried removing and adding spaces around “=” as well.
Please help
March 26th, 2013 on 12:28 pm
Hi All,
I am trying to Deploy/Redeploy one EAR file using WLST scripts. for couple of time it will be success but after that it will start giving below error.
‘Java.lang.OutOfMemoryError: PermGen space’
as I checked in setDomainEnv.sh, below Memory arguments are there.
MEM_ARGS=”-Xms2200m -Xmx2200m -XX:MaxPermSize=512m”
MEM_MAX_PERM_SIZE=”-XX:PermSize=128m -XX:MaxPermSize=192m”
please advice me how can I resolve this problem.
August 27th, 2013 on 3:43 am
I need to undeploy all the applications from the domains(having different clusters,no. of app 40 are targeted on diff diff cluster) and then have to deploy it back.
How can we achieve using WLST script.
October 3rd, 2013 on 8:00 pm
Hi Jay,
Actually when i ran this script, it will stop if one of application not got deployed properly, and second thing is, is it possible to change the name of app, for example if i don’t want .jar in appname?
December 9th, 2013 on 7:23 pm
Hello,
We have 7 managed servers in our cluster CLS01, the application is to be deployed only on 5 servers (MS1, MS2…MS5) out of seven.
Is there a way by which we can specify the specific cluster targets while deploying through wlst. Rather than deploying it to whole cluster.
Regards
Kapil A
June 12th, 2014 on 12:33 pm
Hi JaySenSharma
Please provide WLST deployment is Linux environment.
Thanks,
Narayana