Configuring a Weblogic server for running Oracle Advanced Management Console

If you are trying to run Weblogic using Docker, having automatic configuration of Weblogic is among the best things ever. Once you have created the scripts for the automatic configuration, that is.
As I started to setup Weblogic for Oracle Advanced Management Console (AMC), I noticed that there were a lack of examples covering the settings needed for AMC. This resulted in needing to piece together different examples that covered what I wanted to achieve. The settings I tried to use came from Oracle’s guide to setting up Weblogic for AMC using the Web GUI, https://docs.oracle.com/javacomponents/advanced-management-console-2/install-guide/toc.htm. I built the script for Weblogic 12.2.1.3.

I based my Docker image of Oracle’s Docker example, https://github.com/oracle/docker-images/tree/master/OracleWebLogic. There they set up Weblogic in 2 containers. One for the admin server and another one for the server meant to host AMC. Weblogic Scripting Tool (WLST) is used to set up the Weblogic server. I used WLST online, for more info on WLST see https://docs.oracle.com/cd/E13222_01/wls/docs90/config_scripting/using_WLST.html.

AMC is packaged into a .ear file that Weblogic runs. I had placed the AMC .ear file at ‘/amc/’ (‘/amc/JavaAMC-2_13.ear’) on the container meant to run AMC. A database is required to run AMC. You can use either an Oracle or MySQL database. For my setup I went with MySQL.

The WLST files from the Oracle examples helps you setup the containers so they are ready to be configured for the specific product that you want to install. To configure Weblogic for AMC I wrote a WLST that automates a large chunk of the manual steps from Oracle’s guide. My WLST file set up the following in Weblogic

  • Set JTA to 300 seconds
  • Deploy JAX-RS 2.0 as a library
  • Create a data source
  • Deploy Oracle Advanced Management Console
import os

# commonfuncs.py from Oracle example
execfile('/u01/oracle/commonfuncs.py')

# Set all variables from values in properties file.
dsName=os.environ.get('MYSQL_DATABASE', 'amc2')
dsJNDIName='amc2/db/mysql'
dsURL='jdbc:mysql://YOUR.DATABASE.URL:YOUR_DB_PORT/'+dsName
dsDriver='com.mysql.jdbc.Driver'
dsUsername=os.environ.get('MYSQL_USER', 'amc2')
dsPassword=os.environ.get('MYSQL_PASSWORD', 'Password!1')
domain=os.environ.get('DOMAIN_NAME', 'YOUR.DOMAIN.com')

# Have the settings made for the entire cluster
#dsTargetType='Cluster'
#dsTargetName='DockerCluster'

# Have settings made for the specific server
dsTargetType='Server'
dsTargetName='MS1'

# Connect to the AdminServer
# ==========================
connectToAdmin()

# Deploying JAX-RS 2.0
# Can't deploy while in exclusive edit mode.
print('Deploying JAX-RS 2.0')
progress= deploy(appName='jax-rs',path='/u01/oracle/wlserver/common/deployable-libraries/jax-rs-2.0.war',targets='MS1', libraryModule='true')

# Entering exclusive edit mode
editMode()

# Java Transaction API, Timeout Seconds value
print('Setting timeout seconds to 300 for domain '+domain)
cd('/JTA/'+domain)
cmo.setTimeoutSeconds(300)

# Create data source.
cd('/')
cmo.createJDBCSystemResource(dsName)

cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName)
cmo.setName('AMC_DB')

cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDataSourceParams/' + dsName)
set('JNDINames',jarray.array([String(dsJNDIName)], String))
set('GlobalTransactionsProtocol', java.lang.String('None'))

cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName)
cmo.setUrl(dsURL)
cmo.setDriverName(dsDriver)
set('Password', dsPassword)

cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCConnectionPoolParams/' + dsName)
cmo.setMaxCapacity(30)
cmo.setTestTableName('SQL SELECT 1 FROM DUAL\r\n\r\n')

cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName + '/Properties/' + dsName)
cmo.createProperty('user')
cmo.createProperty('useUnicode')
cmo.createProperty('characterEncoding')

cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName + '/Properties/' + dsName + '/Properties/user')
cmo.setValue(dsUsername)

cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName + '/Properties/' + dsName + '/Properties/useUnicode')
cmo.setValue(java.lang.String('yes'))
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName + '/Properties/' + dsName + '/Properties/characterEncoding')
cmo.setValue(java.lang.String('UTF-8'))

cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDataSourceParams/' + dsName)

cd('/SystemResources/' + dsName)
set('Targets',jarray.array([ObjectName('com.bea:Name=' + dsTargetName + ',Type=' + dsTargetType)], ObjectName))

# Saving and exiting exclusive edit mode
saveActivate()

# Deploying Oracle Advanced Management Console
print('Deploying Oracle Advanced Management Console')
progress= deploy(appName='AMC',path='/amc/JavaAMC-2_13.ear',targets='MS1')

# Exit
# ====
exit()

The function os.environ.get(‘ENVIRONMENT_VARIABLE_NAME’, ‘DEFAULT_VALUE’) gets the value from an environment variable with name matching the first parameter if it’s set. Otherwise it will use the second parameter as default value.

The variable ‘dsJNDIName’ should not be changed if you plan to use MySQL.
‘dsURL’ & ‘domain’ needs to be updated with values for your setup.

The WLST will configure the Weblogic server and deploy AMC, but it won’t configure the settings inside of AMC. This is something you will have to do manually or research further into on your own. Hopefully this will push your AMC deployment further towards automation.

Leave a Reply

Close Menu