Search code examples
javanetbeansjbosswildflyprofiler

Netbeans profile Wildfly Selected methods


I want to profile a selected method in a project that runs in a wildfly server. When the profiler is setup and the method is called the console will give the following exception: java.lang.NoClassDefFoundError: org/netbeans/lib/profiler/server/ProfilerRuntimeCPUFullInstr

Steps to reproduce this problem is as following:

  • start wildfly server through Netbeans > Services > Servers > start Wildfly
  • Profile > Attach to Project
  • Setup Attach to Project > select proces (jboss-modules.jar)
  • Select Methods to profile
  • Select inside Methods to profile "Selected Method"
  • add method from own project and apply
  • run method, the exception will be thrown and the profiler is disconnected

I'm using Netbeans 8.1 and Wildfly 8.2.

What i've tried so far:

  • adding -Djboss.modules.system.pkgs=org.jboss.byteman,org.netbeans.lib.profiler.server
  • http://i-proving.com/2011/07/07/how-to-get-visualvm-to-profile-jboss-without-crashing/ but this gave me the following errors: /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/lib/visualvm/profiler/lib/jfluid-server-15.jar: line 1: PK: command not found /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/lib/visualvm/profiler/lib/jfluid-server-15.jar: line 2:,�*E: command not found /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/lib/visualvm/profiler/lib/jfluid-server-15.jar: line 3:+�*E���+BBMETA-INF/MANIFEST.MFManifest-Version:: No such file or directory /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/lib/visualvm/profiler/lib/jfluid-server-15.jar: line 4: Ant-Version:: command not found /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/lib/visualvm/profiler/lib/jfluid-server-15.jar: line 5: syntax error near unexpected token (' /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/lib/visualvm/profiler/lib/jfluid-server-15.jar: line 5:Created-By: 1.7.0_45-b18 (Oracle Corporation)
  • I also tried to start wildfly in profile mode but this hangs after: Profiler Agent: Waiting for connection on port 5140 (Protocol version: 16)

Solution

  • This should be fixed soon in the nightly builds. Otherwise if you don't want to use the nightly, this is what you'd need to do on your WildFly instance to be able to connect the profiler to it and profile your method. In standalone.sh you will need to update certain options :

    • append jfluid-server.jar to the bootclasspath (or you could change the command line to use -classpath jboss-modules.jar:jfluid-server.jar org.jboss.modules.Main instead of -jar jboss-modules.jar)
    • add the jfluid package to the system.pkgs like this : jboss.modules.system.pkgs=org.jboss.byteman,org.jboss.logmanager,org.netbeans.lib.profiler.server
    • add the -Xverify:none to avoid error messages