dev@glassfish.java.net

Re: How to diagnose "unable to resolve artifact" problem

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Fri, 18 Apr 2008 16:59:59 -0700

Roberto dropped by and we did an investigation. Turns out this was an
issue with the mirror set up. I filed an issue as
http://jira.codehaus.org/browse/MNG-3533

Kohsuke Kawaguchi wrote:
> The process of investigating "unable to resolve artifact" is fairly
> mechanical, for most cases.
>
>
> The first thing to do is to see if the artifact in question makes sense
> to you. Sometimes, mainly due to unexpected property value expansions
> (or failure there of), Maven tries to download an artifact that it's not
> supposed to. For example, if you see Maven downloading
> "org.glassfish:javax.javaee:${javaee.version}", then you can tell that
> somehow Maven failed to expand "javaee.version" property.
>
> This is often hard to investigate, especially when it happens through
> transitive dependencies and project inheritance. "mvn
> help:effective-pom" is a possibly useful tool, as it shows you the
> effective POM after all the project inheritance and what not.
>
>
>
>
> If the artifact in question appears to be legitimate, the next thing to
> look is to check if such an artifact is really supposed to exist. This
> we do by using a browser and look at our Maven repositories. Our bits
> are split across 4 repositories --- the central repository (which you
> can search from http://www.mvnrepository.com/), Glassfish repository,
> java.net maven1 and java.net maven2 repositories. The latter three are
> all available on http://maven.dyndns.org/
>
> If it's not there, then either it's a programming mistake and someone
> put an incorrect version in there, or someone forgot to publish the said
> artifact (this happens if that person commits a POM change before the
> artifact gets deployed by Hudson.)
>
> If it's there, then it's a download problem. The network outage could be
> a cause of this, so is the proxy setting. But by far the most likely
> cause is that Maven wasn't looking into the right locations. The error
> message from Maven always include where Maven looked for the artifact,
> so you need to check this list to make sure it contains the right
> location. If it's not, then we are missing some <repository>
> declarations in our POM.
>
>
>
> In all cases, "mvn -e" is your friend --- seeing the stack trace often
> helps you see the root cause, which gets masked otherwise.
>
>
>
> Hmm... maybe I should expand this a little more and put it into Wiki.
>
>
> Roberto Chinnici wrote:
>> I checked out the trunk from svn and deleted my local maven repository
>> and I still get a build error.
>>
>> My question to you is: what do you do in this kind of situations?
>>
>> If (I'm guessing...) it's an issue with the java.net repository taking a
>> long time to be updated, do you use the on-SWAN mirror?
>>
>> Is there any other meaningful way to recover from this sort of problems?
>>
>> I first got this error several hours ago.
>>
>> Thanks,
>> Roberto
>>
>>
>> ====
>>
>> [INFO]
>> ------------------------------------------------------------------------
>> [ERROR] BUILD ERROR
>> [INFO]
>> ------------------------------------------------------------------------
>> [INFO] Failed to resolve artifact.
>>
>> Missing:
>> ----------
>> 1) com.sun.enterprise:hk2-maven:jar:0.2
>>
>> Try downloading the file manually from the project website.
>>
>> Then, install it using the command:
>> mvn install:install-file -DgroupId=com.sun.enterprise
>> -DartifactId=hk2-maven \
>> -Dversion=0.2 -Dpackaging=jar -Dfile=/path/to/file
>>
>> Path to dependency:
>> 1)
>> org.glassfish.build:maven-glassfish-plugin:maven-plugin:1.0-SNAPSHOT
>> 2) com.sun.enterprise:hk2-maven:jar:0.2
>>
>> ----------
>> 1 required artifact is missing.
>>
>> for artifact:
>> org.glassfish.build:maven-glassfish-plugin:maven-plugin:1.0-SNAPSHOT
>>
>> from the specified remote repositories:
>> central (http://repo1.maven.org/maven2),
>> maven2.java.net (http://download.java.net/maven/2),
>> glassfish-repository (http://download.java.net/maven/glassfish),
>> java.net (http://download.java.net/maven/1)
>>
>>
>> [INFO]
>> ------------------------------------------------------------------------
>> [INFO] For more information, run Maven with the -e switch
>> [INFO]
>> ------------------------------------------------------------------------
>> [INFO] Total time: 2 minutes 22 seconds
>> [INFO] Finished at: Fri Apr 18 13:46:04 PDT 2008
>> [INFO] Final Memory: 21M/38M
>> [INFO]
>> ------------------------------------------------------------------------
>>
>>
>
>


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com