【问题标题】:Using displayLogs() in WLSTInterpreter NameError: displayLogs在 WLSTInterpreter NameError 中使用 displayLogs():displayLogs
【发布时间】:2015-01-23 18:16:03
【问题描述】:

我正在尝试从 displayLogs() 命令获取日志输出,并且尝试在 WLST 解释器中执行此操作。我收到以下错误,即“NameError:displayLogs”我能够执行其他命令,例如 domainRuntime() 和其他一些命令,但这似乎超出了范围。运行它时,我是否需要在类路径中使用某种类来运行它?任何帮助将不胜感激。

我使用的源代码如下:

package wlst;
import weblogic.management.scripting.utils.WLSTInterpreter;
import org.python.util.InteractiveInterpreter;
import org.python.core.PyObject;

public class EmbeddedWLST
{
  static InteractiveInterpreter interpreter = null;
  EmbeddedWLST() {
    interpreter = new WLSTInterpreter();
  }

private static void connect() {
    StringBuffer buffer = new StringBuffer();
    buffer.append("connect('USERNAME','PASSWORD','t3://HOSTANAME:PORT')");
    interpreter.exec(buffer.toString());
}

public static void main(String[] args) {
    new EmbeddedWLST();
    connect();
    PyObject cmo = interpreter.get("cmo");
    String command = getLogs();
    System.out.println("Executing Get Logs");
    interpreter.exec(command);
    System.out.println("Getting Output Object");
    PyObject output = interpreter.get("output");
    System.out.println(output.getClass());
    System.out.println(output);
  }

    private static String getLogs() {
        StringBuffer buf = new StringBuffer();
        buf.append( "output = displayLogs(returnData=1)\n" );
        return buf.toString();
    }
}

【问题讨论】:

    标签: java weblogic wlst


    【解决方案1】:

    更新


    您正在寻找的一切都生活在:

    <install dir>/oracle_common/common/wlst
    

    一个简单的grep -R displayLogs *返回了你需要的python模块:

    <install dir>/oracle_common/common/wlst/oracle-logging.py
    

    您需要在类路径中包含脚本所需的 jar,特别是在 &lt;install dir&gt;/oracle_common/modules/oracle.odl 下找到的日志记录 jar ojdl.jar

    以上信息是通过对比下面的脚本找到的(我用的是10.3.6):


    此脚本 &lt;install dir&gt;/wlserver_10.3/common/bin/wlst.sh 失败:

    wls:/offline> listLogs()
    Traceback (innermost last):
      File "<console>", line 1, in ?
    NameError: listLogs
    

    这个脚本&lt;install dir&gt;/oracle_common/common/bin/wlst.sh 成功(并且比上面的脚本有更多的选项):

    wls:/offline> listLogs()
    Not connected to a Weblogic server. Connect to a Weblogic server first.
    

    确保您设置了与第二个脚本相同的所有 jar 和属性。

    【讨论】:

    • 我知道它可能是一个需要包含的 JAR,但是我看不到具体是哪一个。
    • 更新了你需要的python脚本
    • 我使用的是 12.1.3,但我发现它需要运行 python 文件interpreter.execfile("ORACLE_HOME/oracle_common/common/wlst/OracleODL.py");
    • wlst目录下没有OracleODL.py文件怎么办?
    猜你喜欢
    • 2010-10-29
    • 1970-01-01
    • 1970-01-01
    • 2015-09-22
    • 1970-01-01
    • 1970-01-01
    • 2013-10-12
    • 2018-02-28
    • 1970-01-01
    相关资源
    最近更新 更多