I am trying to attach the Netbeans profiler to my Java project but it get stucked with Connecting to the target vm
.
I found this old bug report but that is already fixed. My version is 7.1.2 with Java 1.7.0_04 on windows 7.
I tried to disable the firewall and start Netbeans as administrator but still i got the same problem.
A bit strange is that calibration works fine.
I have the feeling it's a problem with Java 7. Because if I have look into profiler\lib\deployed
there is no jdk17 folder. Only jdk16 and jdk15.
Any thoughts?
I found out the profiler works if I attach it dynamically. Therefor you have to start the application first (with a break point). Then you click Profile > Attach Profiler... In the top select your project and attach a local dynamical profiler. If you already created the wrong one you can change it at the bottom of the Attach Profiler dialog. Now select the running process and that's it.
I had the same problem using NetBeans 8.0.2 to profile a junit test in a multi-module maven project.
I worked around it by extracting the test into a standalone maven project and adding the other modules as dependencies.
The reason it doesn't work in the multi-module project is that when clicking Profile Test File NetBeans generates an incorrect command line. E.g. in the multi-module project, it produces:
cd C:\test; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.8.0_40" cmd /c "\"\"C:\\Program Files\\NetBeans 8.0.2\\java\\maven\\bin\\mvn.bat\" -Dtest=PerfTest -DforkMode=once -Dmaven.surefire.debug=${exec.args} -Dexec.args= -Dmaven.ext.class.path=\"C:\\Program Files\\NetBeans 8.0.2\\java\\maven-nblib\\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 surefire:test\""
whereas it should be:
cd C:\test; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.8.0_40" cmd /c "\"\"C:\\Program Files\\NetBeans 8.0.2\\java\\maven\\bin\\mvn.bat\" -Dtest=PerfTest -DforkMode=once -Dmaven.surefire.debug=${exec.args} -Dexec.args=\"-agentpath:\\\"C:/Program Files/NetBeans 8.0.2/profiler/lib/deployed/jdk16/windows-amd64/profilerinterface.dll\\\"=\\\"C:\\Program Files\\NetBeans 8.0.2\\profiler\\lib\\\",5140,10 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=C:\\Users\\foo\\AppData\\Local\\NetBeans\\Cache\\8.0.2\\mavencachedirs\\2029222463\\org-netbeans-modules-profiler \" -Dmaven.ext.class.path=\"C:\\Program Files\\NetBeans 8.0.2\\java\\maven-nblib\\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 surefire:test\""
TL;DR - the -Dexec.args= argument is empty in the multi-module project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With