I am trying to run JProfiler for grails application. I would really appreciate any suggestions with the following: 1) Since I don't have an explicit class with main() method in grails application, I am assuming Attaching to a running JVM is my only option. Is that true? Is there a way I could attach JProfiler before the grails application starts? 2) After attaching to a running JVM, what does JProfiler need inorder to profile the controller/service/src/domain files. Do I have to execute the test cases. In my case they are rest controllers so do I have to run the requests for all possible scenarios? 3) Is it possible to have the Jprofiler profile the code without me running the test cases, since I may not be able cover all scenario's?
1 Answers
Since I don't have an explicit class with main() method in grails application
A JVM profiler does not depend on a main method that is written by yourself. The only thing you have to be able to do is to pass the -agentpath
VM parameter to the JVM. The exact parameter is given by Session->Integration wizard->New Remote Integration
in JProfiler and has to be added to the environment variable GRAILS_FORK_OPTS
for Grails >= 3.1.5.
The Intellij IDEA integration can profile Grails run configurations directly, so you don't have to do the above.
Using the attach API is also possible, but has a higher overhead when connecting and prevents some profiling capabilities from being enabled.
do I have to run the requests for all possible scenarios
The profiler profiles the entire JVM, so whatever use case you run while profiling will show up in the profiler.

- 46,523
- 10
- 71
- 102
-
Thanks a lot for your response Ingo. "The Intellij IDEA integration can profile Grails run configurations directly, so you don't have to do the above. " How could I do this so that I could profile the application startup? – clr meno Mar 27 '17 at 17:34
-
Install the JProfiler plugin in IDEA select the grails run configuration and click on the profile button in the tool bar. In the session startup dialog in JProfiler, select a recording profile that includes CPU profiling. Then it profiles the entire startup of the application server. – Ingo Kegel Mar 27 '17 at 21:22
-
I am getting the following error on click of the profile button in the tool bar: loader constraint violation: when resolving method "kotlin.reflect.KClasses.getMemberProperties(Lkotlin/reflect/KClass;)Ljava/util/Collection;" the class loader (instance of com/intellij/ide/plugins/cl/PluginClassLoader) of the current class, com/jprofiler/integrations/idea/runner/f, and the class loader (instance of com/intellij/util/lang/UrlClassLoader) for the method's defining class, kotlin/reflect/KClasses, have different Class objects for the type kotlin/reflect/KClass used in the signature – clr meno Mar 28 '17 at 09:22
-
I will post the complete stack trace in the answer section due to the character restriction for comments – clr meno Mar 28 '17 at 09:23
-
In stackoverflow, you should not post answers with more information or switch to a different issue in the same question, I would recommend to delete your answer. Since I will have to provide you with a new build, please send the stack trace to support@ej-technologies.com together with the IDEA version number that you are using. – Ingo Kegel Mar 28 '17 at 10:02
-
Sure. I have deleted the error log and sent the stack trace to support email. Your quick response is much appreciated. – clr meno Mar 28 '17 at 12:52