Here we are going to see a Scenario which is very common but troublesome. Many times we observe that while trying to restart the Managed Servers the Servers move to ADMIN State rather than moving to the RUNNING State.  This usually happens  If it is unable to activate some of the Modules which are deployed on this Server. usually it happens If any Application is Not getting activated properly or a Datasource or JTA recovery or a JMS System / SubSystem is not getting activated properly then also it moves into the Admin State. So To find out the Root cause we need to keenly observer the Logs. Specially we need to check what configuration changes we made on the Server recently.

More Alerts On the same Monitoring:  http://middlewaremagic.com/weblogic/?p=5838

Most Probable Cause: Most of the cases it happens if any of the Database is down and WebLogic tries to create the Connection Pool at the boot up time.  One way to avoid this kind of scenario is to set the InitialCapacity of the DataSource to  0 (Zero) so that weblogic will not try to create any JDBC Connection object at the start up time so like this we can avoid Connection creation failure conditions and avoid moving our server to ADMIN State.

NOTE: We have an option to forcibily move our WLS Server to the RUNNING State (from ADMIN State) which works almost 80% cases….Still it is must that we find the root cause of Why the Server is moving to ADMIN State.  So please consider this article as a Workaround …And not as a solution. Because even if we can bring our server in RUNNING state …still we have to find out why the Server Moved to ADMIN State.

In this Demonstration we will see a simple WLST script which will check if any of the server present inside Domain is in ADMIN State or not?  If YES then it will try to force them to move to RUNNING State.

Step1). Create a Directory somewhere in your file system like :  “C:\WLST_AdminStateCheck”

Step2). Write a Properties file “domain.properties” inside “C:\WLST_AdminStateCheck” like following:
domain.name=7001_Plain_Domain

totalServersToMonitor=2
server.1.url=t3://localhost:7001
server.2.url=t3://localhost:7003

#############################################################################
#
#
#############################################################################

from java.io import FileInputStream

propInputStream = FileInputStream("domain.properties")
configProps = Properties()

domainName=configProps.get("domain.name")
totalServerToMonitor=configProps.get("totalServersToMonitor")

i=1
while (i <= int(totalServerToMonitor)) :
url=configProps.get("server."+ str(i)+".url")
serverRuntime()
state=cmo.getState()
name=cmo.getName()
print "ALERT::::::::Server Name: " + name + " Is currently in State: " + state
try:
print 'Resuming Server: .....'
cmo.resume()
print "Server: "+name +"Moved to State : " + cmo.getState()
except:
print "NOTE:::::::::Unable to Move Server: " + name + " To good State"
else:
print ''
print ''
print "GOOD::::::::> Server Name: " + name + " Is currently in State: " + state + '                     <img src="http://middlewaremagic.com/weblogic/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley"> '
i = i + 1

Step4). Run the “. ./setWLSEnv.sh” by adding two DOTs separated by a single space …..before the actual script like following : (use ‘cd’ command to move inside the <BEA_HOME>/wlserver_10.3/server/bin) then run the following command….
.  ./setWLSEnv.sh

Note: the first DOT represents that set the Environment in the current Shell, AND the second ./ represents execute the script from the current directory.

Step5). Now run the WLS Script like following:

Following would be the output:

java weblogic.WLST serverAdminState.py

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Connecting to t3://localhost:7001 with userid weblogic ...

Warning: An insecure protocol was used to connect to the
server. To ensure on-the-wire security, the SSL port or

Location changed to serverRuntime tree. This is a read-only tree with ServerRuntimeMBean as the root.
For more help, use help(serverRuntime)

GOOD::::::::> Server Name: AdminServer Is currently in State: RUNNING                     <img src="http://middlewaremagic.com/weblogic/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley">
Connecting to t3://localhost:7003 with userid weblogic ...
Successfully connected to managed Server 'ManagedServer-1' that belongs to domain '7001_Plain_Domain'.

Warning: An insecure protocol was used to connect to the
server. To ensure on-the-wire security, the SSL port or

Server: ManagedServer-1Moved to State : RUNNING