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 197235 - Add Dependency fails to add repository declaration
Summary: Add Dependency fails to add repository declaration
Status: RESOLVED WONTFIX
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 7.0
Hardware: All All
: P4 normal (vote)
Assignee: Tomas Stupka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-30 14:09 UTC by Tomas Danek
Modified: 2016-12-16 17:43 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 Tomas Danek 2011-03-30 14:09:10 UTC
Product Version: NetBeans IDE 7.0 RC1 (Build 201103300000)
Java: 1.6.0_24; Java HotSpot(TM) 64-Bit Server VM 19.1-b02-334
System: Mac OS X version 10.6.7 running on x86_64; MacRoman; en_US (nb)
Userdir: /Users/tomas/.netbeans/7.0rc1
-----------------------------------

Something wrong about my usecase??

- create simple maven java project
- add dependency on e.g. o.n.swing.dirchooser.jar
- project shows missing dependency, which cannot be resolved
- clean and build produces:

cd /Users/tomas/NetBeansProjects/tmpPrj1; JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home "/Applications/NetBeans/NetBeans 7.0 RC1.app/Contents/Resources/NetBeans/java/maven/bin/mvn" clean install
Scanning for projects...
                                                                        
------------------------------------------------------------------------
Building tmpPrj1 1.0-SNAPSHOT
------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/org/netbeans/modules/org-netbeans-swing-dirchooser/RELEASE70-BETA2/org-netbeans-swing-dirchooser-RELEASE70-BETA2.pom

The POM for org.netbeans.modules:org-netbeans-swing-dirchooser:jar:RELEASE70-BETA2 is missing, no dependency information available
Downloading: http://repo1.maven.org/maven2/org/netbeans/modules/org-netbeans-swing-dirchooser/RELEASE70-BETA2/org-netbeans-swing-dirchooser-RELEASE70-BETA2.jar

------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 1.421s
Finished at: Wed Mar 30 15:28:53 CEST 2011
Final Memory: 3M/81M
------------------------------------------------------------------------
Failed to execute goal on project tmpPrj1: Could not resolve dependencies for project com.mycompany:tmpPrj1:jar:1.0-SNAPSHOT: Could not find artifact org.netbeans.modules:org-netbeans-swing-dirchooser:jar:RELEASE70-BETA2 in central (http://repo1.maven.org/maven2) -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
Comment 1 Jesse Glick 2011-03-30 16:10:21 UTC
You also need

    <repositories>
        <repository>
            <id>netbeans</id>
            <url>http://bits.netbeans.org/maven2/</url>
        </repository>
    </repositories>

With that it works:

import javax.swing.JFileChooser;
import org.netbeans.swing.dirchooser.Module;
public class App {
    public static void main(String[] args) {
        Module.install();
        JFileChooser fc = new JFileChooser();
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        fc.showOpenDialog(null);
    }
}

Probably this ought to have been added by the Add Dependency dialog, given that the artifact is not available in any of the repositories previously associated with the project.
Comment 2 Jesse Glick 2011-03-30 16:11:13 UTC
BTW the first suggestion in the linked wiki page gives this explanation.
Comment 3 Milos Kleint 2012-04-24 13:41:51 UTC
(In reply to comment #1)
> You also need
> 
>     <repositories>
>         <repository>
>             <id>netbeans</id>
>             <url>http://bits.netbeans.org/maven2/</url>
>         </repository>
>     </repositories>
> 
> 
> Probably this ought to have been added by the Add Dependency dialog, given that
> the artifact is not available in any of the repositories previously associated
> with the project.

I would refrain from adding repository elements to poms for the following reasons:
1. it's not recommended, "best" practice. Almost always a pom without repository entries is advertised.
2. with mirrors in settings and especially star mirrors, it's not entirely clear what should be added as repository and under which conditions. Eg. never add mirror repositories? add the original repository url for non star mirrors with just one mirrored repo?

we do add repositories for netbeans related content and since we own both the code and the repository, it's sort of ok.
Comment 4 Jesse Glick 2012-04-24 16:55:59 UTC
Perhaps should display a prompt so the user can decide whether to have a repository definition added. Even displaying a warning might suffice, so that the build failure is not mysterious. (Is it straightforward to determine from the A.D. dialog that the currently configured set of repositories does not contain the selected artifact?)

Alternately, only load indices corresponding to the project's effective repositories, so that this bug never comes up to begin with - if you want to even look for artifacts from other repositories (*) you would need to add them first, ideally with an Alt-INSERT snippet in the POM.

(*) Whether automatic registrations from other open projects with different configuration, or manually added indices.
Comment 5 Milos Kleint 2012-06-05 07:04:30 UTC
(In reply to comment #4)
> Perhaps should display a prompt so the user can decide whether to have a
> repository definition added. Even displaying a warning might suffice, so that
> the build failure is not mysterious. (Is it straightforward to determine from
> the A.D. dialog that the currently configured set of repositories does not
> contain the selected artifact?)

we sort of know what index it came from (I believe) however we (or indexer) make no effort aggregate repo ids in case the artifact entry is in multiple repositories (so sometimes you get "local" as repository even though it's in other defined repositories as well.

and with mirrors we cannot really be sure what the actual repository is the artifact coming from. In * mirrors i's obvious but even non-star mirrors suffer from that. the id is just a label, can represent multiple urls based on context. Consider this case <mirrorOf>apache,central,codehaus</mirrorOf>. Some other project references apache, so in the IDE we know the mirror is mirroring apache AND central. However we cannot decide if the artifact is coming from apache, central or codehaus. In case of codehaus we don't even know the url to use.

> 
> Alternately, only load indices corresponding to the project's effective
> repositories, so that this bug never comes up to begin with - if you want to
> even look for artifacts from other repositories (*) you would need to add them
> first, ideally with an Alt-INSERT snippet in the POM.
> 

Well, we're only in the situation because of the netbeans repository (and java.net formerly). That's the only repository that we manually add, everything else comes from user own's setup. in 7.0 it was probably hardwired, now it's only manually added and immediately removed when we search for platform version in the project wizards. 
So a maven newbie will always only the results from central unless he adds a repository himself or keeps a project with repository entry opened.

and as jesse pointed out, the failed build points to the wiki with answers to the problem.
Comment 6 Jesse Glick 2012-06-05 16:52:33 UTC
(In reply to comment #5)
> we cannot really be sure what actual repository is the artifact coming from

Right, but I do not think you need to know this. All you need to know is whether the project in its current configuration could resolve the artifact somehow - which is something the embedder should be able to tell you. If not, even though the IDE might not be able to determine exactly what needs to be changed, at least it can display a warning that the user needs to do something.

> in 7.0 [the 'netbeans' repo] was probably hardwired

Yes, no more.

> now it's
> only manually added and immediately removed when we search for platform version
> in the project wizards.

Which makes no difference for purposes of the Add Dependency dialog.

Probably P4 for the reasons discussed here - the problem will no longer occur commonly.
Comment 7 eduardocosta 2015-05-07 02:44:58 UTC
Hi there. 

I had similar issue using Netbeans 8.0.2, when I build a maven project within the netbeans the build failed with the error "...RELEASE80 is missing, no dependency information available". If I add the netbeans repository (http://bits.netbeans.org/nexus/content/groups/netbeans/) within my project uber pom.xml all woks fine. 

In my case I just move the netbeans repository to my setting.xml and I configured the netbeans to do not use the embedded maven it should use my external maven installation rather than.  

Now my project build with success within the netbeans and on command line.
Comment 8 Martin Balin 2016-07-07 08:38:49 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
Comment 9 Zoltan Levardy 2016-12-16 17:43:00 UTC
MacOS NB 8.2 still not downloading dependencies. From command line I need to copy paste the missing grpid:arti:ver to install by mvn commmand, example:
$ mvn dependency:get -Dartifact=com.google.code.maven-replacer-plugin:maven-replacer-plugin:1.3

It does not matter if using out-dated 3.0.5 called "Bundled", or using the /usr/local/Cellar/maven/3.3.9/libexec - both giving the same error as missing, then I need to install by mvn command to my local .m2 repo

thx