我可以独立连接WLST并在其他脚本中使用它的功能吗?

1 投票
2 回答
1642 浏览
提问于 2025-04-17 22:56

我有一个脚本叫做 conn.py,里面有一个函数叫 conn(),这个函数用 connect(username,password,url) 来连接 weblogic 域。还有一个脚本叫 createServer.py

__main__: 
    import conn
conn.conn() 
cmo.createServer()

但是在运行 createServer() 的时候出现了错误,似乎在我运行 conn.conn() 之后自动断开了连接。我该怎么做才能继续使用 WLST 在线功能呢?

---------------------我的控制台返回的信息是-------------

starting the script ....
input your user name : weblogic
input your user password : weblogic456
Connecting to t3://localhost:7001 with userid weblogic ...
Successfully connected to Admin Server 'AdminServer' that belongs to domain 'demo'.

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

connect OK.

You will need to be connected to a running server to execute this command


You will need to be connected to a running server to execute this command

Error: No domain or domain template has been read.
Problem invoking WLST - Traceback (innermost last):
  File "/home/chopperlee/Program/Workspace/configWL/wlst/createServer.py", line 84, in ?
  File "/home/chopperlee/Program/Workspace/configWL/wlst/createServer.py", line 37, in createServer
AttributeError: 'NoneType' object has no attribute 'createServer'

2 个回答

0

WLST的connect函数会设置一些全局变量,这些变量在Python中其实是模块级别的全局变量——在你的例子里,就是conn模块的全局变量,而不是整个Python运行环境的全局变量。

所以,connect函数实际上是在你的conn模块的上下文中工作的。其他依赖于连接并检查连接状态的WLST命令,如果在conn模块内部调用,可能会正常工作。

但是,从你的主脚本或者从主脚本调用的WLST命令是看不到conn模块中记录连接的全局变量的,因此,当你从主脚本运行需要连接的WLST命令时,它们就会失败。

0

请你检查一下"createServer.py"文件的第37行和第84行,看看里面有没有缺少的参数。

撰写回答