Problem with JavaProgramPatcher and server integrations(Tomcat, Jetty...)

I am using JavaProgramPatcher to add parameter used by VisualVM, and then start VisualVM in DefaultJavaProgramRunner or GenericDebuggerRunner which results in opened tab in VisualVM on currently runned application. My current solution is not very clean, I save the parameter appended at JavaProgramPatcher to some static variable, and then use it at the Runner to start the VisualVM.

Problem is, that it does not work for Tomcat, because the Patcher is runned at different points - at configuration menu, and after the application was actually started ( which is also after my VisualVM was started).

Any ideas?

the plugin + source:

Comment actions Permalink

VM parameters are passed to application servers via an environment variable and value of that variable is shown in the run configuration editor (on
'Startup/Connection' tab). So IDEA needs to invoke patchers for appserver run configurations several times, to show the value and to actually start
the process.

To ensure that the same appId is passed to the command line and used to start VisualVM you can store it in RunnerSettings (implement
ProgramRunner#createConfigurationData) like GenericDebuggerRunner stores the debug port. Unfortunately RunnerSettings isn't propogated to
JavaProgramPatcher so you need to override 'GenericProgramRunner#doExecutedoExecute' methods in your runners to patch the command line.

Nikolay Chashnikov
Software Developer
JetBrains, Inc
"Develop with pleasure!"

Comment actions Permalink

Thank, it seems to be working reliably, after hours of hacking :^O

JavaProgramPatcher was great because it was runned even for default and JRebel executions. Too bad that it takes RunProfile instead of RunnerSettings.X-( But I figured out, that I can use both methods, because the java parameter could be happily used multiple times.

Now only problem is that my console button for launching VisualVM does not work for Tomcat with default executors, because ConsoleActionsPostProcessor is called before JavaProgramPatcher, which is unusual... If only all Run/Debug configuration types used similar workflow...
I understand that it was not meant to do this, but I could not find any other way how to add buttons (for Debug, Run was easy).


Please sign in to leave a comment.