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 206750 - Erratic behavior when localRepository not initially configured
Summary: Erratic behavior when localRepository not initially configured
Status: RESOLVED WONTFIX
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 7.1
Hardware: PC Linux
: P4 normal (vote)
Assignee: Tomas Stupka
URL:
Keywords:
Depends on: 167208
Blocks: 206754
  Show dependency tree
 
Reported: 2011-12-27 18:33 UTC by massimo
Modified: 2016-07-07 08:39 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
screen shot of open maven project dialog (1.09 MB, image/png)
2011-12-27 18:48 UTC, massimo
Details
shows unloadable project after compiling successfully (74.12 KB, image/png)
2011-12-27 19:30 UTC, massimo
Details
loaded projects in Projects which will be now detected by NB Open Project Dialog (76.12 KB, image/png)
2011-12-27 19:38 UTC, massimo
Details
More unloadable projects (85.70 KB, image/png)
2011-12-27 19:44 UTC, massimo
Details
Open Project Dialog that lists more projects (48.43 KB, image/png)
2011-12-27 19:47 UTC, massimo
Details
Shows the correct list of required projects after setting maven home in NB first. (77.37 KB, image/png)
2011-12-27 20:07 UTC, massimo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description massimo 2011-12-27 18:33:09 UTC
Product Version = NetBeans IDE 7.1 RC2 (Build 201111302200)
Operating System = Linux version 2.6.32-35-generic running on amd64
Java; VM; Vendor = 1.6.0_25
Runtime = Java HotSpot(TM) 64-Bit Server VM 20.0-b11

When opening a top level project in maven and checking "Open Required Projects" used to open also all source dependencies. With Netbeans 7.1RC2 it no longer does that the first time around.
I did this right after installing NB 7.1RC2, and NB only opened the direct children of my top level maven project, which happen to be also container projects having no sources.
This is odd because the second time i did this, NB did open all required sources correctly. It just does not seem to do that the first time around after installation.
I am going to now check if by closing and reopening NB it still does that. I am also going to wipe out the .netbeans directory to see if i will reproduce consistently.
Comment 1 massimo 2011-12-27 18:48:37 UTC
Created attachment 114489 [details]
screen shot of open maven project dialog

The open project dialog for the top level container project called "src" does not gather the correct "required projects". The list showing on the right hand side under the Open Required Projects checkbox is completely wrong.
Comment 2 massimo 2011-12-27 19:08:30 UTC
I can reproduce this consistently now. After removing the .netbeans directory, you can see from the attached screenshot how by selecting the top level pom project (src) the required projects are not detected correctly.

Going to attach another screenshot next and describe the steps i took to work around this issue and show that it no longer happens once all has been loaded once.
Comment 3 massimo 2011-12-27 19:30:10 UTC
Created attachment 114490 [details]
shows unloadable project after compiling successfully

The attached screenshot shows "unloadable" projects, children of project src/sdk.

I got to that point after bulding src successfully.

I should probably mention that before building, i went to Tools->Options->Misc->Maven to point to my installation of Maven, which is also 3.0.3.
Here is the result of mvn --version from terminal:

mvn --version
Apache Maven 3.0.3 (r1075438; 2011-02-28 09:31:09-0800)
Maven home: /home/max/apps/apache-maven-3.0.3
Java version: 1.6.0_25, vendor: Sun Microsystems Inc.
Java home: /home/max/apps/jdk1.6.0_25/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-35-generic", arch: "amd64", family: "unix"

I need to use my installation of maven, because i need to point to my repository, which is not the default $HOME/.m2/repository (see filed bug 205735).

Note that by right-clicking on sdk at this point and choosing "Open Required Projects" does not open the required projects at all (which is also a bug, as NB used to do that).

I then double-click on each one (api, crosslanguage, impl,...), which finally opens them all in Projects. 
I then select them all, right-click and choose "Reload POM" and finally the alert badge goes away (see next screenshot).
Comment 4 massimo 2011-12-27 19:38:58 UTC
Created attachment 114491 [details]
loaded projects in Projects which will be now detected by NB Open Project Dialog

This screenshot shows the 6 children of sdk now opened and refreshed (Reload POM) as described in the previous step.

The screenshot also shows an icon on the bottom right of the IDE, which prompts you to run a priming build of src (which i am not exactly sure what it means, sounds like a new 7.1 feature, will read about). After clicking run a priming build, does not help the situation: going back to open project in the attempt to get to open the required project, it still does not list them correctly. However there is a difference now: the list at the bottom right of the Open Project Dialog with src selected now shows the 6 projects that i opened manually. The list is still wrong, because it does not show the children projects of src/harness for example, but it now shows the 6 children of src/sdk (see next screenshot). In that next screenshot i also show how the children of harness are unloadable.
Comment 5 massimo 2011-12-27 19:44:06 UTC
Created attachment 114492 [details]
More unloadable projects

Again, i load (by double-clicking on each) all sub-projects manually: harness/engine, harness/runner, harness/data. Then select them and do "Reload POM" and they show without alert badge.
Now i go to Open Project, select src, and they now show.
Netbeans will now remember this forever (until i erase the .netbeans directory).
Comment 6 massimo 2011-12-27 19:47:34 UTC
Created attachment 114493 [details]
Open Project Dialog that lists more projects

This screenshot shows the open project dialog after performing the last step as described above.
Again, the list is still wrong, but improved by the fact that i opened sub-projects manually in Projects.

The list of required projects in the bottom right of the Open Project dialog does not list the child projects based on pom parsing, but seems to instead list them based on what is loaded in Projects.
Comment 7 massimo 2011-12-27 20:07:00 UTC
Created attachment 114494 [details]
Shows the correct list of required projects after setting maven home in NB first.

Found a workaround to this issue. Here is the use case to reproduce.
Pre-requisites:
*first install of NB7.1 RC2 or erase .netbeans first.
*the maven repository is not in its default location $HOME/.m2/repository, but it is set in a different location as specified in your $MAVEN_HOME/conf/settings.xml.

Steps:
Launch NB 7.1 RC2.
Go to Tools->Options->Misc->Maven and set Maven home to your system's maven home.
Go to File->Open Project and select the top-level pom.
The list of required projects now shows correctly (see screenshot).
Comment 8 massimo 2011-12-27 20:10:08 UTC
Going to leave this issue opened, because this was not the behavior in previous releases of NB.
NB 7.1 RC2 seems to behave erratically when it comes to opening maven projects if you do not specify your maven home first and if the local maven repo is not the default one.
Comment 9 massimo 2011-12-27 20:22:46 UTC
Thought i mentioned of another bug that seems related to this one, which i have just reported off of an exception coming out of NB after compiling src: 553750.

Note that my system home is /mts/home4/mcalderoni:
echo $HOME
/mts/home4/mcalderoni
But again, please note that i do not want my local maven repository to be:
/mts/home4/mcalderoni/.m2/repository
I want that to instead be as specified in my $MAVEN_HOME/conf/settings.xml in its localRepository tag:
  <localRepository>/home/max/.m2/repository</localRepository>
(please note that /home/max is not home! and max is not a system user either: /home/max is just a plain directory, which was created with mcalderoni privileges).

Again, seems like NB is not handling a non-default maven local repo correctly.
Comment 10 massimo 2011-12-27 20:34:01 UTC
Issue seems related to bug 205735 and bug 553750.
Comment 11 Jesse Glick 2011-12-27 22:06:10 UTC
Simpler would be to configure localRepository in ~/.m2/settings.xml, in which case there is no need to configure anything in the IDE. Setting a special Maven home is only necessary in case you have configuration in $MAVEN_HOME/conf/settings.xml which cannot be kept in ~/.m2/settings.xml.
Comment 12 massimo 2011-12-27 23:15:53 UTC
Good point, thank you. I removed the localRepository tag from $MAVEN_HOME/conf/settings.xml and created ~/.m2/settings.xml with localRepository set in there, and verified that opening the top-level project with required projects works fine.

Another advantage of this is that settings.xml now also shows under the Project Files node in NB Projects view, allowing direct editing, while it would not show under that node even if i set the M2 environment variable to my non-default m2 directory containing the local repository (see "pitfall" bug 205734, unsure if re-opening that bug, just re-edited it).
Comment 13 massimo 2011-12-27 23:37:13 UTC
my apologies: after double-checking in the maven documentation, looks like it is my misinterpretation that by setting an M2 env variable maven understands that a non-default m2 can be used. There seem to be no way to tell maven to point to a different location for ~/.m2 altogether.

This issue still holds although it has a good workaround: just wanted to rectify my last comment.
Comment 14 ebratt 2012-01-04 21:01:40 UTC
I see this problem in my GlassFish (actually GlassFish MQ) build. Because we use the hk2 Maven plugin, we must use Maven 2.2.1. I start with an empty local Maven cache. I update the NB 7.1 RC2 installation to use the correct version of Maven. The project shows "unloadable;" I run the priming build. This build succeeds, but the project remains unloadable. The error in the "Show and Resolve Errors is:
the artifact junit:junit:jar:3.8.1 is not available in the local repository 
(This isn't needed for my build, but appears to be necessary for NetBeans to parse the project source.)
Repository configuration is defined in $(home)/.m2/settings.xml
If I manually download the correct JAR file from my repository --re-run the priming build, the build completes, Netbeans thinks a bit, and the "Unloadable" moniker is removed. (Yea!)
In 7.0.1, When I first open the project (starting with an empty local maven repository), it at first reports that the project is misconfigured. Opening up the "Show and Resolve Errors" panel indicates that NetBeans is trying to download all the dependencies. Eventually, this succeeds and the project model is created and the Misconfigured" moniker is removed. So, it works in NM 7.0.1, but not in Beta2, or RC2. Seems like the method that NB uses to get the online repository is different in 7.1? (I couldn't find any place else to configure the online repository location).
Comment 15 Jesse Glick 2012-01-04 21:29:58 UTC
(In reply to comment #14)
> Seems like the method that NB uses to get the online
> repository is different in 7.1?

Not sure what you mean by "online repository". NB uses the same remote repository definitions as command-line Maven does: any in ~/.m2/settings.xml, <mavenhome>/conf/settings.xml, pom.xml, and the built-in Central definition.

Not obvious that you are seeing the same bug as massimo. As always, steps to reproduce from scratch will improve your changes of a fix.
Comment 16 Milos Kleint 2012-06-05 09:48:39 UTC
(In reply to comment #14)
> I see this problem in my GlassFish (actually GlassFish MQ) build. Because we
> use the hk2 Maven plugin, we must use Maven 2.2.1. I start with an empty local
> Maven cache. I update the NB 7.1 RC2 installation to use the correct version of
> Maven. The project shows "unloadable;" I run the priming build. This build
> succeeds, but the project remains unloadable. The error in the "Show and
> Resolve Errors is:
> the artifact junit:junit:jar:3.8.1 is not available in the local repository 
> (This isn't needed for my build, but appears to be necessary for NetBeans to
> parse the project source.)
> Repository configuration is defined in $(home)/.m2/settings.xml
> If I manually download the correct JAR file from my repository --re-run the
> priming build, the build completes, Netbeans thinks a bit, and the "Unloadable"
> moniker is removed. (Yea!)
> In 7.0.1, When I first open the project (starting with an empty local maven
> repository), it at first reports that the project is misconfigured. Opening up
> the "Show and Resolve Errors" panel indicates that NetBeans is trying to
> download all the dependencies. Eventually, this succeeds and the project model
> is created and the Misconfigured" moniker is removed. So, it works in NM 7.0.1,
> but not in Beta2, or RC2. Seems like the method that NB uses to get the online
> repository is different in 7.1? (I couldn't find any place else to configure
> the online repository location).


I believe I've fixed something along these lines lately. The problem was basically that 3.0.4 maven that we use in project loading expects certain metadata to be present in local repository, otherwise it will declare a dependency missing even though the jar file is physically there. My fixed involved bypassing this mechanism that is meant to ensure that the artifact is loadable with the given set of remote repositories. However using 2.1 to build didn't create these pieces of metadata.
Comment 17 Milos Kleint 2012-06-05 09:50:40 UTC
based on comments closing as wontfix, please reopen if I misunderstood something
Comment 18 Jesse Glick 2012-06-05 17:01:22 UTC
Problem mentioned in comment #14 is probably unrelated. Originally reported problem seems to be that fix of bug #167208 is not honored when settings or Maven home changed on the fly. Possibly duplicate of bug #206754?
Comment 19 Martin Balin 2016-07-07 08:39:11 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss