简体   繁体   中英

WLST data source and unknown host

I'm using the online WLST script to configure the WebLogic server during Docker image build. Basically the docker image build starts up the WebLogic and executes the following script

import os

import time
import getopt
import sys
import re

# Deployment Information
domainname = os.environ.get('DOMAIN_NAME', 'base_domain')
domainhome = os.environ.get('DOMAIN_HOME', '/u01/oracle/user_projects/domains/' + domainname)
cluster_name = os.environ.get("CLUSTER_NAME", "DockerCluster")
admin_name = os.environ.get("ADMIN_NAME", "AdminServer")

connect(username,password,server_url)
edit()


print ""
print "================== DataSource ==================="
startEdit()

# Create Datasource
# ==================
cd('/')
cmo.createJDBCSystemResource(dsname)

cd('/JDBCSystemResources/' + dsname + '/JDBCResource/' + dsname)
cmo.setName(dsname)

cd('/JDBCSystemResources/' + dsname + '/JDBCResource/' + dsname)
cd('JDBCDataSourceParams/' + dsname)
set('JNDINames', jarray.array([String(dsjndiname)], String))

cd('/JDBCSystemResources/' + dsname + '/JDBCResource/' + dsname)
cd('JDBCDriverParams/' + dsname)
cmo.setDriverName(dsdriver)
cmo.setUrl(dsurl)
set('PasswordEncrypted', encrypt(dspassword))

print 'create JDBCDriverParams Properties'
cd('Properties/' + dsname)
cmo.createProperty('user')
cd('Properties/user')
cmo.setValue(dsusername)

print 'create JDBCConnectionPoolParams'
cd('/JDBCSystemResources/' + dsname + '/JDBCResource/' + dsname)
cd('JDBCConnectionPoolParams/' + dsname)
set('TestTableName','SQL SELECT 1 FROM DUAL')

# Assign
# ======
#assign('JDBCSystemResource', dsname, 'Target', admin_name)
#assign('JDBCSystemResource', dsname, 'Target', cluster_name)
cd('/SystemResources/' + dsname)

set('Targets',jarray.array([ObjectName('com.bea:Name=' + targetname + ',Type=' + targettype)], ObjectName))


# Update Domain, Close It, Exit
# ==========================
#save()
activate()

print ""
#disconnect()
exit()

The problem is, the database host doesn't exists at the build time, as it is the container name of another docker container in the docker-compose environment. With this script, setting the target on data source throws exception, as the host name couldn't be resolved, thus the activate call fails, as well as all the following WLST scripts which depends on the data source. Yet, I don't want to manually set the target after the whole environment is up and running. How do I avoid the exception in this case?

将数据源的初始容量和最小容量设置为0,这可以在不进行测试的情况下进行激活,并且应跳过您的错误。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM