WebLogic-在“中使用环境变量/双引号”;“论点”;在;“服务器启动”;
我有一个管理服务器、NodeManager和一个托管服务器,都在同一台机器上。 我试图在“服务器开始”选项卡的“参数”字段中输入类似的内容:WebLogic-在“中使用环境变量/双引号”;“论点”;在;“服务器启动”;,weblogic,weblogic-10.x,weblogic11g,weblogic12c,Weblogic,Weblogic 10.x,Weblogic11g,Weblogic12c,我有一个管理服务器、NodeManager和一个托管服务器,都在同一台机器上。 我试图在“服务器开始”选项卡的“参数”字段中输入类似的内容: -Dmy.property=%USERPROFILE%\someDir\someJar.jar 但当托管服务器启动时,会引发以下异常: 打开zip文件或缺少JAR清单时出错:%USERPROFILE%\someDir\someJar.JAR 似乎没有将环境变量转换为其值。它只是以纯文本形式传递给托管服务器。 我尝试用双引号(“)包围路径,但控制台验证输入
-Dmy.property=%USERPROFILE%\someDir\someJar.jar
但当托管服务器启动时,会引发以下异常:
打开zip文件或缺少JAR清单时出错:%USERPROFILE%\someDir\someJar.JAR
似乎没有将环境变量转换为其值。它只是以纯文本形式传递给托管服务器。
我尝试用双引号(“)包围路径,但控制台验证输入,不允许这样做:“参数可能不包含'”
即使手动编辑config.xml文件也无法工作,因为在此之后管理服务器无法启动:
<Critical> <WebLogicServer> <BEA-000362> <Server failed. Reason: [Management:141266]Parsing failure in config.xml: java.lang
.IllegalArgumentException: Arguments may not contain '"'.>
我也尝试过使用%20,但没有效果,它只是作为%20传递
我认为这可能与%USERPROFILE%
的值中的空格有关(即“C:\documents and settings…”),但其他环境也会发生同样的情况。指向没有空格的其他目录的变量
我的问题:
是否有支持的方式:
根据评论进行编辑: 方法1:
export SERVER_NAME
,或在Windows中搜索set SERVER_NAME
。跳到下一行(即跳过当前行和下一行)customServerList="server1,server2" #this serverList should be taken as input
isCurrServerCustom=$(echo ${customServerList} | tr ',' '\n' | grep ${SERVER_NAME} | wc -l)
if [ $isCurrServerCustom -gt 0 ]; then
# add customJavaArg
JAVA_OPTIONS="-Dmy.property=${USERPROFILE}/someDir/someJar.jar"
fi
-Dmy.property
的服务器列表。Jython脚本(使用wlst.sh执行)
用法:wlst.sh脚本\u名称道具\u文件\u位置
import os
from java.io import File
from java.io import FileInputStream
# extract properties from properties file.
print 'Loading input properties...'
propsFile = sys.argv[1]
propInputStream = FileInputStream(propsFile)
configProps = Properties()
configProps.load(propInputStream)
domainDir = configProps.get("domainDir")
# serverList in properties file should be comma seperated
serverList = configProps.get("serverList")
# The current machine's logical name as mentioned while creating the domain has to be given. Basically the machine name on which NM for current host is configured on.
# This param may not be required as an input if the machine name is configured as same as the hostname , in which case , socket module can be imported and socket.getHostName can be used.
currMachineName = configProps.get("machineName")
jarDir = os.environ("USERPROFILE")
argToAdd = '-Dmy.property=' + jarDir + File.separator + 'someDir' + File.separator + 'someJar.jar'
readDomain(domainDir)
for srvr in serverList.split(",") :
cd('/Server/' + srvr)
listenAddr = get('ListenAddress')
if listenAddr != currMachineName :
# Only change current host's servers
continue
cd('/Server/' + srvr + '/ServerStart/' + srvr)
argsOld = get('Arguments')
if argsOld is not None :
set('Arguments', argsOld + ' ' + argToAdd)
else:
set('Arguments', argToAdd)
updateDomain()
closeDomain()
# now restart all affected servers (i.e serverList)
# one way is to connect to adminserver and shutdown them and then start again
脚本必须从要部署托管服务器的所有主机上运行,以便在JVM参数中具有特定于主机的“USERPROFILE”值
顺便说一句,在一行中回答您的问题:看起来JVM参数最终必须与文本一起提供。但是如果作为JVM参数提供,WLS看起来不会转换环境变量。它给人的印象是,当它从startwebogic.cmd(例如:使用%DOMAIN\u HOME%等)完成时,它正在进行翻译,但它是shell/cmd执行器,负责翻译,然后启动JVM。您是否在windows上运行它?是的,我是。谢谢杰夫指出这一点,我本想这么说的。我还没有尝试在linux上使用相同的${VARIABLE_NAME},我只能假设它会有相同的结果。如何使用startweblog.cmd来确定哪个托管服务器将接收此值?我不希望为域中的所有托管服务器设置此选项,只为它们的特定子集设置。更具体地说,我需要的是为域中的任何服务器子集(可能是分布式服务器)设置此JAVA_选项的方法。子集由用户的输入决定,我事先不知道。在域创建过程中,您为服务器动态设置了ServerStart参数(由用户输入)?域已存在,由用户创建。为了安装我的工具,他提供了他感兴趣的服务器的名称作为输入。然后,我想做的是编辑每个服务器的服务器启动参数(JAVA_选项)。每一个都以相同的方式-添加依赖于env的属性。任何托管服务器上的变量,其中一些服务器可能是分布式的,并且位于远程计算机上。确定。很高兴听到你这么说。我想我没有足够清楚地解释脚本循环。希望你能理解它的工作原理。基本上是这样的:startManagedWebLogic.sh->startweblog.sh->setDomainEnv.sh。任何使用了“导出或设置”的变量值都将结转。