简体   繁体   English

WLST数据源和未知主机

[英]WLST data source and unknown host

I'm using the online WLST script to configure the WebLogic server during Docker image build. 我正在使用在线WLST脚本在Docker映像构建期间配置WebLogic服务器。 Basically the docker image build starts up the WebLogic and executes the following script 基本上,docker映像构建会启动WebLogic并执行以下脚本

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. 问题是,数据库主机在构建时不存在,因为它是docker-compose环境中另一个Docker容器的容器名称。 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. 使用此脚本,由于无法解析主机名,因此在数据源上设置目标会引发异常,因此激活调用以及以下所有依赖于数据源的WLST脚本都会失败。 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,这可以在不进行测试的情况下进行激活,并且应跳过您的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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