【问题标题】:-javaagent option parameter for web application-javaagent 用于 Web 应用程序的选项参数
【发布时间】:2015-03-10 18:03:50
【问题描述】:

我正在尝试使用 Instrumentation 来计算 Web 应用程序中多个对象的内存使用量(准确地说,是基于请求)。

不幸的是,WebLogic 似乎没有插入静态 void premainagentmain

为了完整起见,这里是 Intrumentation 实例化类:

public class InstrumentationInstance {
    private static Instrumentation instrumentation;

    public static void premain(String args, Instrumentation ins){
        instrumentation = ins;
    }
    public static void agentmain(String args, Instrumentation ins){
        instrumentation = ins;
    }

    public static Instrumentation instrumentation(){
        return instrumentation;
    }
}

我尝试将这些添加到清单中,但 Instrumentation 仍然为空:

Manifest-Version: 1.0
Premain-Class: com.things.monitoring.InstrumentationInstance
Agent-Class: com.things.monitoring.InstrumentationInstance
Class-Path: 

看起来这个应用程序需要使用 java 选项 -javaagent 启动,以便注意到 premainagentmain 方法。我认为这将在web.xml/weblogic.xml 文件中完成?但我似乎找不到任何例子或证据表明如何......

【问题讨论】:

    标签: java performance web-applications weblogic monitoring


    【解决方案1】:

    你有几个选择:

    • -javaagent 添加到startWebLogic.sh 脚本的JAVA_OPTIONS 部分。请注意,这将适用于所有服务器

    • -javaagent 添加到管理控制台中的服务器启动参数。导航到 Servers -> Server Name -> Configuration -> Server Start tab 并编辑 Arguments 部分。您也可以在此处添加其他参数,内存参数、-D 参数等。

    这个link 也很好地涵盖了它。我认为这不是你应该放在 weblogic.xml 文件中的东西。

    【讨论】:

    • 我在控制台的服务器中设置参数。但是它似乎没有运行premainagentmain,并且 WebLogic 没有在控制台中给我任何形式的确认或错误
    • 您是否尝试过调试,例如:stackoverflow.com/questions/21733303/…
    • 它与JAVA_OPTIONS 方法一起工作(有点,现在它说它找不到Premain-Class,但是嘿,我们很接近了!)。详细设置没有做任何事情。
    • 好的,如果您想分享更多信息,请随时编辑您的问题或我的详细回答
    猜你喜欢
    • 1970-01-01
    • 2013-09-30
    • 2012-06-22
    • 1970-01-01
    • 2016-02-21
    • 2011-01-07
    • 1970-01-01
    • 2014-10-14
    • 2020-12-24
    相关资源
    最近更新 更多