【问题标题】:How can I connect from IDEA JProfiler plugin to a JVM started without nowait?如何从 IDEA JProfiler 插件连接到无需等待即可启动的 JVM?
【发布时间】:2015-05-18 22:39:17
【问题描述】:

我正在尝试按如下方式分析 JBoss:

  • -agentpath:C:\Progra~1\jprofiler8\bin\windows-x64\jprofilerti.dll 添加到standalone.bat。请注意,nowait 未指定,因此 VM 将等待 JProfiler GUI 连接。
  • 运行standalone.bat
  • 使用“运行 -> 附加到 JVM”从 IDEA 附加

问题是无论我做什么,“快速附加”窗口都看不到 JBoss JVM。

这是显示 JProfiler 准备就绪的 JBoss 标准输出:

Calling "C:\src\ss-master\middle\runtime\jboss-as-7.1.1.Final\bin\standalone.conf.bat"
===============================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: C:\src\ss-master\middle\runtime\jboss-as-7.1.1.Final

  JAVA: C:\tools\java\bin\java

  JAVA_OPTS: -XX:+TieredCompilation -agentpath:C:\Progra~1\jprofiler8\bin\windows-x64\jprofilerti.dll -Dprogram.name=standalone_jprofiler.bat -Xms256m -Xmx8192m -XX:NewRatio=6 -XX:
PermSize=128m -XX:MaxPermSize=256m -Xss512K -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.war
ning=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djboss.server.default.config=standalone.xml -Dorg.jboss.server.bootstrap.maxThreads=8 -agentlib:jdwp=transport=dt_socket,se
rver=y,suspend=n,address=5001

===============================================================================

JProfiler> Protocol version 41
JProfiler> Using JVMTI
JProfiler> JVMTI version 1.1 detected.
JProfiler> 64-bit library
JProfiler> Listening on port: 8849.
JProfiler> Instrumenting native methods.
JProfiler> Can retransform classes.
JProfiler> Can retransform any class.
JProfiler> Native library initialized
JProfiler> VM initialized
JProfiler> Waiting for a connection from the JProfiler GUI ...

以下是我尝试过的一些事情:

  • JProfiler UI 中的“快速附加”也看不到 JBoss VM。
  • 在启动选项中使用nowait,连接成功(即使来自IDEA)。
  • 没有nowait,我只能从JProfiler GUI 中的预定义会话进行连接。之后,我也可以从 IDEA 连接。

最后一点是最有趣的。保存的会话有哪些额外信息可以使它检测到“等待”的 JProfiler 代理?

以下是我的用例的限制:

  • 我想从 IDEA 启动分析,以便跳转到源代码将我带到 IDEA。
  • 我想分析启动阶段,所以无法添加nowait

【问题讨论】:

    标签: jprofiler


    【解决方案1】:

    当分析代理在启动时等待连接时,附加机制不起作用,因为尚未加载启用附加的jvmstat系统。事实上,还没有加载任何 Java 类,因此在那个阶段没有任何需要 Java 代码的代码。

    要分析这样一个等待的虚拟机,您需要一个远程分析会话。在 JProfiler 8 中,IDE 集成不支持此功能。

    这将在 JProfiler 9.0(即将发布)中实现。附加对话框将有两种模式,一种是列出所有本地运行的虚拟机的本地模式,另一种是远程附加选项,您可以在其中输入主机名和端口。

    但是,您也可以直接从 IDEA 分析 JBoss 运行配置。这样就不用修改启动脚本了。

    【讨论】:

    • 感谢您的解释。关于您的建议,我不想从 IDE 运行 JBoss。我需要对各种 JBoss 安装进行概要分析,并且最方便的是仅附加到众多已检测的 JVM 之一(就像您为调试所做的那样)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-28
    • 2021-03-05
    相关资源
    最近更新 更多