This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 203199 - Profiling of Maven-based NBM "suites" does not work
Summary: Profiling of Maven-based NBM "suites" does not work
Status: NEW
Alias: None
Product: apisupport
Classification: Unclassified
Component: Maven (show other bugs)
Version: 7.0
Hardware: All All
: P4 normal (vote)
Assignee: Milos Kleint
URL:
Keywords:
Depends on: 191078 203519
Blocks:
  Show dependency tree
 
Reported: 2011-10-06 08:36 UTC by J Bachorik
Modified: 2012-10-31 15:05 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description J Bachorik 2011-10-06 08:36:21 UTC
During evaluation of #198401 I have total breakage of profiling functionality for Maven NBM and Platform Application projects.
Any attempt to profile these kinds of projects fails with the following exception:

Failed to execute goal org.codehaus.mojo:nbm-maven-plugin:3.6:run-ide (default-cli) on project mavenproject1: The parameters 'netbeansInstallation' for goal org.codehaus.mojo:nbm-maven-plugin:3.6:run-ide are missing or invalid -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:nbm-maven-plugin:3.6:run-ide (default-cli) on project mavenproject1: The parameters 'netbeansInstallation' for goal org.codehaus.mojo:nbm-maven-plugin:3.6:run-ide are missing or invalid
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:221)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.PluginParameterException: The parameters 'netbeansInstallation' for goal org.codehaus.mojo:nbm-maven-plugin:3.6:run-ide are missing or invalid
	at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:576)
	at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:529)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:92)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
	... 19 more


This seems to be caused by some internal changes in the maven project infrastructure.
Comment 1 J Bachorik 2011-10-06 08:43:58 UTC
Fixed by configuring the "netbeans.installation" in the profiler RunCheckerImpl.

http://hg.netbeans.org/profiler-main/rev/16b8e64abb2f
Comment 2 Quality Engineering 2011-10-10 12:24:38 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/16b8e64abb2f
User: Jaroslav Bachorik <yardus@netbeans.org>
Log: #203199: A change in Maven project support for NBM modules and platform applications caused the profiling functionality to break for those project types. Fixed by explicitly configuring the maven goal with "netbeans.installation" property in the profiler RunCheckerImpl.
Comment 3 Jesse Glick 2011-10-11 14:15:19 UTC
This fix looks suspicious to me. I am not sure what your evaluation consisted of. Do you claim that bug #199922 was not in fact fixed, or that the fix regressed between 7.0 and now?

First of all, guessNetbeansInstallation should not exist. ${netbeans.installation} must be defined in your ~/.m2/settings.xml in order to run module suites, much less profile them.

Second, netbeans.installation is used only for module suites and standalone modules, both of which are *deprecated* for Maven since they use an IDE installation on disk (nbm:run-ide goal). The primary use case is running a self-contained application (using nbm:run-platform), which gets everything from the repository and does not need this property. You look to be defining the property for both goals, which is certainly wrong.

I would recommend 16b8e64abb2f be backed out and a more precise description of the current problem, and its relation to prior fixes, be written down.

BTW also please avoid reformatting sections of code you are not semantically modifying.
Comment 4 J Bachorik 2011-10-11 16:25:47 UTC
I have no idea whether bug #199922 was fixed or not. I do suppose it had been as it was verified by the reporter.

I don't know anything about deprecation of the NetBeans Module maven project type - the new project wizard allows me to create this project type without any warnings. You still can invoke Run and Debug actions and they are using nbm:run-ide goal under the hood. 

I am backing out the changeset as requested. After the backout the situation is following:
1. Profiling NetBeans Application projects works
2. Profiling NetBeans Module projects doesn't work - still the same error message "The parameters 'netbeansInstallation'
for goal org.codehaus.mojo:nbm-maven-plugin:3.6:run-ide are missing or invalid" appears
3. Profiling NetBeans Module Suite projects doesn't work at all - profiler completely ignores this kind of packaging

My attempt on fixing this issue was copying/pasting the functionality I found in "maven.apisupport" which takes care of actually invoking run and debug actions on a NetBeans Module project. Specifically, the "guessNetbeansInstallation()" method (which should not exist according to your last comment) was copied over from "maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmActionGoalProvider.java".

Regarding reformatting the code - are you referring to fixing inconsistent 8 space indenting of a private variable where the others are 4 space indented? In this case I prefer fixing it than leaving it be - firstly, the incorrect indenting was plainly a mistake and secondly the noise it brings into the diff is really low being only one such change (I wouldn't do that for en masse of indentation for sure).

I am reassigning the issue to jglick since the fix I provided was the only one that worked for me and I truly have no idea where in maven support to look for additional hints.
Comment 5 J Bachorik 2011-10-11 16:27:09 UTC
Backout changeset:

http://hg.netbeans.org/profiler-main/rev/4eb6e1d31c88
Comment 6 Petr Cyhelsky 2011-10-12 07:56:51 UTC
Does this mean Issue #199922 should be also reopened now?
Comment 7 Jesse Glick 2011-10-12 19:48:38 UTC
(In reply to comment #5)
> Backout changeset:
> 
> http://hg.netbeans.org/profiler-main/rev/4eb6e1d31c88

OK, I will look at it after this propagates; http://deadlock.netbeans.org/hudson/job/profiler-main/lastCompletedBuild/testReport/ is failing currently.
Comment 8 J Bachorik 2011-10-12 22:36:21 UTC
Thanks. 

The profiler-main build should get fixed once a47670c57454 from jet-main gets to profiler-main.
Comment 9 Jesse Glick 2011-10-13 19:19:20 UTC
(In reply to comment #4)
> I don't know anything about deprecation of the NetBeans Module maven project
> type - the new project wizard allows me to create this project type without any
> warnings.

I have added warnings. (The "module" template is fine so long as it is part of an "application". "Suite" is always deprecated.)

> You still can invoke Run and Debug actions and they are using
> nbm:run-ide goal under the hood. 

Right; this is the deprecated mode.

> 1. Profiling NetBeans Application projects works

Which is the important thing, and means that bug #199922 is still fixed.

> 2. Profiling NetBeans Module projects doesn't work - still the same error
> message "The parameters 'netbeansInstallation'
> for goal org.codehaus.mojo:nbm-maven-plugin:3.6:run-ide are missing or invalid"
> appears

Only if you have in fact failed to define this parameter in ~/.m2/settings.xml. It is set automatically when you create a "suite". I have to think about whether there are other places in the UI where it makes sense to set it when it is not yet set.

> 3. Profiling NetBeans Module Suite projects doesn't work at all - profiler
> completely ignores this kind of packaging

Not surprising, since this is a POM project. Possibly needs to be fixed in the archetype rather than the IDE.

> "guessNetbeansInstallation()" method (which should not exist according to your
> last comment) was copied over from
> "maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmActionGoalProvider.java".

I will look for a way to delete this or rework it.
Comment 10 Jesse Glick 2011-10-13 20:52:31 UTC
OK, did some investigation. First of all I dealt with ${netbeans.installation} in a better and more generic way. Anyway this only matters if you do not already have it defined in settings.xml.


Now for the profiler part. To start with, I cannot find the purpose of <profiler.action>...</profiler.action>, in any packaging type. maven.profiler/src/org/netbeans/modules/maven/profiler/ActionMappings.xml seems to be the only file in the source base that even refers to a property of this name. Deleting the several occurrences from ActionMappings.xml seems to have no effect on anything. Perhaps this is left over from some old implementation?


As far as profiling suites goes, the proper approach would be for the archetype to define in nbactions.xml:

    <action>
        <actionName>profile</actionName>
        <goals>
            <goal>package</goal>
            <goal>nbm:cluster</goal>
            <goal>nbm:run-ide</goal>
        </goals>
        <properties>
            <netbeans.run.params.ide>${profiler.args.prefixed} ${profiler.jdkhome.opt}</netbeans.run.params.ide>
        </properties>
    </action>

You can test this by just adding that snippet to a suite project's nbactions.xml. This makes the Profile Project button actually do something. But, RunCheckerImpl.checkRunConfig returns early since sessionProperties == null, because configureProject was never called, because MavenProjectProfilingSupportProvider.isProfilingSupported returns false, because supportedPTypes does not include TYPE_POM.

Nor would we really want to include TYPE_POM in there; for most POM projects, profiling would be utterly meaningless - it is only the weird case of a "suite" project that has run-like actions. But this means that supportedPTypes, besides hardcoding specific packaging types, is not really right - it should rather be examining the action mapping for the project to see if it has ACTION_PROFILE (or perhaps one of the related commands).


On the subject of hardcoding packaging types, I think it is wrong that maven.profiler, in the Java SE IDE, is supplying goals for EE, NBM, etc. projects. Probably ProfilerActionsProvider should be deleted, and the contents of .../maven/profiler/ActionMappings.xml moved into the appropriate modules (maven, maven.j2ee, maven.apisupport). Granted these do not have a dependency on the profiler cluster, but that seems to be a lesser layering violation.
Comment 11 Jesse Glick 2011-10-13 21:01:17 UTC
Suites could not be profiled in 7.0; this was probably never possible.
Comment 12 Quality Engineering 2011-10-14 14:59:27 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/e5bdd4c9a2af
User: Jesse Glick <jglick@netbeans.org>
Log: Ensure netbeans.installation is defined whenever needed. Mentioned in bug #203199.
Comment 13 J Bachorik 2011-10-20 11:23:03 UTC
Jesse, thanks for helping out!

Indeed, a proper integration of the profiler actions into the IDE will be the right way to go. Will address it in #203519.
Comment 14 J Bachorik 2012-04-02 11:30:29 UTC
Profiler side changes implemented in http://hg.netbeans.org/profiler-main/rev/cf681524d222

The profiler actions now utilize the StartupExtender infrastructure to provide correct JVM arguments for the started java process. 

If the profiling of suite projects should work at all the following requirements must be fulfilled:
1. Suite project must have a distinct packaging type
2. suite specific packaging must take into account the JVM args generated by StartupExtender infrastructure
OR
1. POM packaging type must take into account the JVM args generated by StartupExtender infrastructure
2. nbactions.xml in the suite archetype must include the following "profile" action mapping

  <action>
      <actionName>profile</actionName>
      <goals>
          <goal>package</goal>
          <goal>nbm:cluster</goal>
          <goal>nbm:run-ide</goal>
      </goals>
      <properties>
          <netbeans.run.params.ide/>
      </properties>
  </action>
Comment 15 Milos Kleint 2012-10-31 15:05:10 UTC
in http://hg.netbeans.org/core-main/rev/fad8c401388e i've removed the suite wizard from the UI, it's been long marked as not suites for production environments