Java VisualVM hangs connecting to locally process launched from eclipse
Asked Answered
F

7

41

I'm trying to connect jvisualvm installed with jdk1.7.0_04 to a locally running java process. When I do this, jvisualvm shows a progress bar in the bottom left saying its connecting to the process, and then never responds again.

The java process I'm trying to connect to is still fine and works as normal.

I can get a threaddump of visualvm using jstack, that shows 1 blocked thread.

AWT-EventQueue-0" prio=6 tid=0x04a1a000 nid=0x1110 waiting for monitor entry [0x062af000]
   java.lang.Thread.State: BLOCKED (on object monitor)
        at com.sun.tools.visualvm.core.model.ModelFactory.getModel(ModelFactory.java:76)
        - waiting to lock <0x289584f0> (a com.sun.tools.visualvm.jvmstat.application.JvmstatApplication)
        at com.sun.tools.visualvm.core.datasource.descriptor.DataSourceDescriptorFactory.getDescriptor(DataSourceDescriptorFactory.java:49)

I can't connect to any java process, even a trivial one that just waits for user input. I also had the same problem with jdk1.6.0_32.

-- Updates I've since discovered this only affects java processes I launch from eclipse. It's possible to get the command eclipse launched from the debug perspective and opening the process properties. Launching the same process from the command prompt (using the command I copied from eclipse) allows connections from jvisualvm and jconsole.

Full thread dump:

2012-05-10 13:18:47
Full thread dump Java HotSpot(TM) Client VM (23.0-b21 mixed mode, sharing):

"Inactive RequestProcessor thread [Was:TimedSoftReference/org.openide.util.TimedSoftReference]" daemon prio=2 tid=0x00e12800 nid=0xa5c in Object.wait() [0x0587f000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x22d6a578> (a java.lang.Object)
    at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1880)
    - locked <0x22d6a578> (a java.lang.Object)

Locked ownable synchronizers:
    - None

"pool-4-thread-1" prio=6 tid=0x063ddc00 nid=0x1a70 waiting on condition [0x0750f000]
java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x23440068> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1043)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1103)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

Locked ownable synchronizers:
    - None

"pool-3-thread-1" prio=6 tid=0x00fe7400 nid=0x16a0 waiting on condition [0x05a7f000]
java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x28a7ccd8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1043)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1103)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

Locked ownable synchronizers:
    - None

"Timer-1" daemon prio=2 tid=0x04c63800 nid=0x1f00 in Object.wait() [0x07f1f000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x289e6688> (a java.util.TaskQueue)
    at java.util.TimerThread.mainLoop(Timer.java:552)
    - locked <0x289e6688> (a java.util.TaskQueue)
    at java.util.TimerThread.run(Timer.java:505)

Locked ownable synchronizers:
    - None

"TimerQueue" daemon prio=6 tid=0x04b82c00 nid=0x124 waiting on condition [0x070df000]
java.lang.Thread.State: TIMED_WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x285f8b20> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2082)
    at java.util.concurrent.DelayQueue.take(DelayQueue.java:220)
    at javax.swing.TimerQueue.run(TimerQueue.java:171)
    at java.lang.Thread.run(Thread.java:722)

Locked ownable synchronizers:
    - <0x2862c110> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)

"Thread-3" daemon prio=6 tid=0x04b7b400 nid=0x1c18 in Object.wait() [0x06edf000]
java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x28562950> (a java.util.LinkedList)
    at java.lang.Object.wait(Object.java:503)
    at java.util.prefs.AbstractPreferences$EventDispatchThread.run(AbstractPreferences.java:1476)
    - locked <0x28562950> (a java.util.LinkedList)

Locked ownable synchronizers:
    - None

"DataSourceWindowManager Processor" daemon prio=2 tid=0x04b28c00 nid=0x11e0 runnable [0x06cdf000]
java.lang.Thread.State: RUNNABLE
    at sun.tools.attach.WindowsVirtualMachine.connectPipe(Native Method)
    at sun.tools.attach.WindowsVirtualMachine.execute(WindowsVirtualMachine.java:100)
    at sun.tools.attach.HotSpotVirtualMachine.loadAgentLibrary(HotSpotVirtualMachine.java:58)
    at sun.tools.attach.HotSpotVirtualMachine.loadAgentLibrary(HotSpotVirtualMachine.java:79)
    at sun.tools.attach.HotSpotVirtualMachine.loadAgent(HotSpotVirtualMachine.java:103)
    at com.sun.tools.visualvm.jmx.impl.JmxModelImpl$LocalVirtualMachine.loadManagementAgent(JmxModelImpl.java:676)
    - locked <0x23440218> (a com.sun.tools.visualvm.jmx.impl.JmxModelImpl$LocalVirtualMachine)
    at com.sun.tools.visualvm.jmx.impl.JmxModelImpl$LocalVirtualMachine.startManagementAgent(JmxModelImpl.java:633)
    - locked <0x23440218> (a com.sun.tools.visualvm.jmx.impl.JmxModelImpl$LocalVirtualMachine)
    at com.sun.tools.visualvm.jmx.impl.JmxModelImpl$ProxyClient.tryConnect(JmxModelImpl.java:450)
    at com.sun.tools.visualvm.jmx.impl.JmxModelImpl$ProxyClient.connect(JmxModelImpl.java:420)
    at com.sun.tools.visualvm.jmx.impl.JmxModelImpl.connect(JmxModelImpl.java:200)
    at com.sun.tools.visualvm.jmx.impl.JmxModelImpl.<init>(JmxModelImpl.java:170)
    at com.sun.tools.visualvm.jmx.impl.JmxModelProvider.createModelFor(JmxModelProvider.java:45)
    at com.sun.tools.visualvm.jmx.impl.JmxModelProvider.createModelFor(JmxModelProvider.java:22)
    at com.sun.tools.visualvm.core.model.ModelFactory.getModel(ModelFactory.java:91)
    - locked <0x289f8fe0> (a com.sun.tools.visualvm.jvmstat.application.JvmstatApplication)
    at com.sun.tools.visualvm.tools.jmx.JmxModelFactory.getJmxModelFor(JmxModelFactory.java:49)
    at com.sun.tools.visualvm.application.views.threads.ApplicationThreadsViewProvider.resolveThreads(ApplicationThreadsViewProvider.java:63)
    at com.sun.tools.visualvm.application.views.threads.ApplicationThreadsViewProvider.supportsViewFor(ApplicationThreadsViewProvider.java:29)
    at com.sun.tools.visualvm.application.views.threads.ApplicationThreadsViewProvider.supportsViewFor(ApplicationThreadsViewProvider.java:25)
    at com.sun.tools.visualvm.core.ui.DataSourceViewsManager.getViews(DataSourceViewsManager.java:116)
    at com.sun.tools.visualvm.core.ui.DataSourceWindowManager.openWindowAndAddView(DataSourceWindowManager.java:169)
    at com.sun.tools.visualvm.core.ui.DataSourceWindowManager.access$000(DataSourceWindowManager.java:30)
    at com.sun.tools.visualvm.core.ui.DataSourceWindowManager$1.run(DataSourceWindowManager.java:80)
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1385)
    at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1929)

Locked ownable synchronizers:
    - None

"AWT-EventQueue-0" prio=6 tid=0x049fa000 nid=0x1b90 waiting on condition [0x062af000]
java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x28310488> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
    at java.awt.EventQueue.getNextEvent(EventQueue.java:511)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:213)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)

Locked ownable synchronizers:
    - None

"AWT-Windows" daemon prio=6 tid=0x049cc000 nid=0x12b0 runnable [0x0608f000]
java.lang.Thread.State: RUNNABLE
    at sun.awt.windows.WToolkit.eventLoop(Native Method)
    at sun.awt.windows.WToolkit.run(WToolkit.java:299)
    at java.lang.Thread.run(Thread.java:722)

Locked ownable synchronizers:
    - None

"AWT-Shutdown" prio=6 tid=0x049cb400 nid=0x1954 in Object.wait() [0x05e8f000]
java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x28430620> (a java.lang.Object)
    at java.lang.Object.wait(Object.java:503)
    at sun.awt.AWTAutoShutdown.run(AWTAutoShutdown.java:287)
    - locked <0x28430620> (a java.lang.Object)
    at java.lang.Thread.run(Thread.java:722)

Locked ownable synchronizers:
    - None

"Java2D Disposer" daemon prio=10 tid=0x010a4000 nid=0x1dd4 in Object.wait() [0x05c8f000]
java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x28378258> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
    - locked <0x28378258> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
    at sun.java2d.Disposer.run(Disposer.java:145)
    at java.lang.Thread.run(Thread.java:722)

Locked ownable synchronizers:
    - None

"CLI Requests Server" daemon prio=6 tid=0x01058000 nid=0x1a58 runnable [0x0567f000]
java.lang.Thread.State: RUNNABLE
    at java.net.TwoStacksPlainSocketImpl.socketAccept(Native Method)
    at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:398)
    at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:183)
    - locked <0x28378700> (a java.net.SocksSocketImpl)
    at java.net.ServerSocket.implAccept(ServerSocket.java:522)
    at java.net.ServerSocket.accept(ServerSocket.java:490)
    at org.netbeans.CLIHandler$Server.run(CLIHandler.java:1042)

Locked ownable synchronizers:
    - None

"Active Reference Queue Daemon" daemon prio=2 tid=0x01028c00 nid=0x17b4 in Object.wait() [0x049af000]
java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x28378878> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
    - locked <0x28378878> (a java.lang.ref.ReferenceQueue$Lock)
    at org.openide.util.lookup.implspi.ActiveQueue$Impl.run(ActiveQueue.java:64)
    at java.lang.Thread.run(Thread.java:722)

Locked ownable synchronizers:
    - None

"Timer-0" daemon prio=6 tid=0x01015400 nid=0x1ce8 in Object.wait() [0x047af000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x28378910> (a java.util.TaskQueue)
    at java.util.TimerThread.mainLoop(Timer.java:552)
    - locked <0x28378910> (a java.util.TaskQueue)
    at java.util.TimerThread.run(Timer.java:505)

Locked ownable synchronizers:
    - None

"Service Thread" daemon prio=6 tid=0x00e7b400 nid=0x4a8 runnable [0x00000000]
java.lang.Thread.State: RUNNABLE

Locked ownable synchronizers:
    - None

"C1 CompilerThread0" daemon prio=10 tid=0x00e76000 nid=0x13e0 waiting on condition [0x00000000]
java.lang.Thread.State: RUNNABLE

Locked ownable synchronizers:
    - None

"Attach Listener" daemon prio=10 tid=0x00e74400 nid=0x448 waiting on condition [0x00000000]
java.lang.Thread.State: RUNNABLE

Locked ownable synchronizers:
    - None

"Signal Dispatcher" daemon prio=10 tid=0x00e73000 nid=0x1eb4 runnable [0x00000000]
java.lang.Thread.State: RUNNABLE

Locked ownable synchronizers:
    - None

"Finalizer" daemon prio=8 tid=0x00e60400 nid=0x1f28 in Object.wait() [0x03b1f000]
java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x28378b58> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
    - locked <0x28378b58> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:177)

Locked ownable synchronizers:
    - None

"Reference Handler" daemon prio=10 tid=0x00e5ec00 nid=0x1d40 in Object.wait() [0x0391f000]
java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x283782e8> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:503)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)
    - locked <0x283782e8> (a java.lang.ref.Reference$Lock)

Locked ownable synchronizers:
    - None

"main" prio=6 tid=0x00db8000 nid=0x12f0 waiting on condition [0x00000000]
java.lang.Thread.State: RUNNABLE

Locked ownable synchronizers:
    - None

"VM Thread" prio=10 tid=0x00e5d000 nid=0xbf8 runnable 

"VM Periodic Task Thread" prio=10 tid=0x00e7e800 nid=0x1fcc waiting on condition 

JNI global references: 656
Fowkes answered 8/5, 2012 at 7:2 Comment(10)
Do jconsole and jmap work?Forebear
@Forebear - jmap works fine and I can obtain a binary heap dump. jconsole also can't establish a connection. The 'Connecting to <pid>' progress slider bounces back and forth forever. Note that if I've attempted to connect with either jconsole or jvisualvm first to the process, then jmap also fails to connect.Fowkes
Please post the whole thread dump of VisualVM, not just AWT-EventQueue.Unprofessional
@TomasHurka stackoverflow will not let me attach the full threaddump.Fowkes
I see. You can upload the thread dump somewhere else (like pastebin.com) and put the link here.Unprofessional
@TomasHurka thread dump can be found here pastebin.com/Swr7h5JjFowkes
It looks like the problem is in "DataSourceWindowManager Processor" thread. It tries to attach to monitored application via Attach API and freezes. I am not sure why it does not work only for processes launched from eclipse - are you using Eclipse launcher visualvm.java.net/eclipse-launcher.html ?Unprofessional
@TomasHurka I'm not using the eclipse launcher plugin.Fowkes
I don't know why, but this is no longer an issue. Able to connect fine again with no issues.Fowkes
I think that I have the same problem that lukestevo was having. jvisualvm will connect, but it takes a full 6 minutes, every time, like a TCP timeout or something?Arboreous
D
27

Please check your network configuration.

I expericened the same issue. It can work when I set network configuration with 'No Proxy'. Main menu: tools/options/network/no proxy.

Diplostemonous answered 25/7, 2012 at 14:43 Comment(2)
The problem resolved itself, I'm not sure why. I was connecting to locally running processes, so wouldn't have thought the proxy settings would have any impact.Fowkes
thanks for the tip. Took me quite a while to nail down to this silly proxy issue...Nebulosity
K
18

Try to add the following VM arguments to your "Run Configurations":

-Djava.rmi.server.hostname=localhost

Run configuration

Krefetz answered 24/3, 2016 at 3:45 Comment(0)
S
18

Found this on a VisualVM mailing list: https://java.net/projects/visualvm/lists/users/archive/2016-06/message/7

Added this:

-J-Dorg.netbeans.profiler.separateConsole=true

to my jvisualvm.exe shortcut and it works!

Stumpage answered 17/11, 2016 at 14:30 Comment(4)
Had the same issue as Konstantin and this solved it. Thank youTana
Worked for me too. Windows 10 with the x63 version of jdk1.8.0_102.Tayler
How do you add this to the shortcut?Christos
This post and its comments may help you https://mcmap.net/q/384424/-visualvm-cpu-memory-profiler-stuck-at-quot-connecting-to-the-target-jvm-quot to add the command line option to your visualvm instance.Foregone
M
5

I was experiencing the same problem and I am behind a proxy. Selecting either 'No Proxy' or 'Manual proxy settings' resolves the issue.

Such a simple thing, and I have wasted a couple of hours on this...

Minimus answered 22/2, 2013 at 21:2 Comment(0)
T
5

In my case the solution was to use 32bit jsdk.
To diagnose start jvisualvm with param --trace ..

my log contained:
Cannot load C:\Program Files\Java\jdk1.7.0_45\jre\bin\server\jvm.dll. %1 is not a valid Win32 application. (193) Falling back to running Java in a separate process; DLL cannot be loaded (64-bit DLL?).

Trichina answered 3/10, 2014 at 16:47 Comment(0)
I
1

Sometimes Skype sits on weird ports... This has caused me major headaches on at least two occasions, when it chose 8080, and I thought my Tomcat is corrupted. It turned out (after an hour or so of being totally clueless and unsuspecting), that Skype was using that port...

Also a question: did you start your program in 'Run' or 'Debug' mode from Eclipse?

Ignacia answered 11/10, 2012 at 7:26 Comment(0)
V
0

add the follwing argument in eclipse runConfigurations augments tab

-XX:+StartAttachListener

this will allow visualVM to connect instantly and sample and profiling will work.

Vouvray answered 17/6, 2015 at 0:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.