开发者

Inspecting a java application which has been started with -javaagent using VisualVM

I am trying to inspect an java application using VisualVM. Normally there is no problem but I am trying to set up Eclipselink weaving and so I am starting the program using the -javaagent flag;

-Xms1024m -Xmx1582m -Xshare:off  -javaagent:C:\Users\Administrator\.m2\repository\org\eclipse\persistence\eclipselink\2.3.0-M7\eclipselink-2.3.0-M7.jar

When I look at the program using Viusal VM I can see nothing on the Monitor pag开发者_开发问答e.

Unfortunately the VisualVM docs site (at visualvm.java.net ) seems to be down.

Thanks to anyone who can help me understand what I am doing wrong.


Thanks to Tomas Hurka of Oracle I can answer this question.

The problem is caused by a timeout between when the jvm is detected and when it is initialized by jvmstat (http://java.sun.com/performance/jvmstat/). With weaving turned on this interval obviously increased.

There are 2 ways to fix this.

1) you can explicitly enable JMX in monitored application on predefined port with

-Dcom.sun.management.jmxremote.port=<portNum>
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false

and from VisualVM attach to your application via File->Add JMX connection and use "localhost:" as a connection string.

2) You can up the timeout;

a) In the visualvm /etc directory (e.g. visualvm_132\etc) edit the defaults_opts setting in visualvm.conf so that -J-Dsun.jvmstat.perdata.syncWaitMs=10000 is increased as necessary ( I increased it *10 to 100 seconds)

VisualVM also has a log file available through Help->About->Log file which shows any exceptions which have been thrown. In here I found the stack trace of the timeout...

INFO [com.sun.tools.visualvm.jvmstat.JvmstatModelProvider]: Could not get MonitoredVM
sun.jvmstat.monitor.MonitorException: Could not synchronize with target
   at sun.jvmstat.perfdata.monitor.v2_0.PerfDataBuffer.synchWithTarget(PerfDataBuffer.java:262)

Thanks again to Tomas. He should get any points from this

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜