maven failing on dependency that isn't actually in the project - maven

My build is failing with this error message (corporate stuff crossed out):
[ERROR] Failed to execute goal on project XXXX: Could not resolve
dependencies for project XXXX: The following artifacts could not be
resolved:
com.github.chrisbanes.actionbarpulltorefresh:library:jar:0.9.3,
com.github.castorflex.smoothprogressbar:library:jar:0.2.0: Cannot
access XXXX-release (http://repo.XXXX.corp/main/repo) in offline mode
and the artifact
com.github.chrisbanes.actionbarpulltorefresh:library:jar:0.9.3 has not
been downloaded from it before. -> [Help 1]
The funny thing is that actionbarpulltorefresh is not a dependency of this project. I double-checked and the string appears nowhere in the directory. It's a dependency of another project I built a couple of days ago, but not this one. It's also not mentioned in my users's settings.xml file, or anywhere in .m2 except that it's actually installed there.
Where could that error possibly be coming from?

It might be a transitive dependency, a dependency of a dependency.
This question might help you: How to determine which Maven dependency is needing a missing dependency?

Related

mvn dependency:purge-local-repository fails in multi-module project

We have a maven project structure like this:
Parent
L A
L B
A depends on B
Both have various dependencies on other libs
Building this with mvn clean install works fine, but when we try to prune all dependencies as described here with
mvn dependency:purge-local-repository
We get an error saying that it can't resolve the dependency to B:jar:snapshot-version:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.10:purge-local-repository (default-cli) on project A: Failed to refresh project dependencies for: A:jar:4.0.1-SNAPSHOT: required artifacts missing:
[ERROR] B:jar:6.0-5
My current interpretation is that during an actual build B gets build first and can get resolved, but during the purge nothing gets build so the resolution fails. But the project is there and its dependencies should get purged. How can I fix this?
-DactTransitively=false
doesn't seem to change anything.
While it doesn't seem to be the exact issue referenced by #Tunaki the example in there let me try this:
mvn dependency:purge-local-repository -DreResolve=false
Which got rid of the exception but failed to actually reload the dependency I had problems with. At which point I came across this answer which made me try
mvn dependency:purge-local-repository -DreResolve=false -DactTransitively=false
which solved the problem although it seems to requesting the opposite of what I wanted to achieve :-/
This looks like a bug with the maven-dependency-plugin (JIRA issue MDEP-405) introduced by a regression in Maven 3.0.4.
From Paul Gier's comment:
I think the reason this happens is because in order to determine the full set of transitive dependencies to delete, the poms need to be available. If the poms were already resolved in the previous module, Maven won't re-resolve them again and just fails. So the dependency doesn't have a problem with the file already being deleted from the local repo, but the maven dependency resolution code fails when trying to resolve the same file twice in the same build.
You might try the build with Maven 3.0.3 because there was a change in this in Maven 3.0.4:
http://mail-archives.apache.org/mod_mbox/maven-dev/201210.mbox/%3C5752023.Vp0WJBo1vZ%40bigmax%3E
This is linked to the regression MNG-5366, that is currently unresolved.
I don't see any real work-around apart from downgrading Maven.

Maven Could not resolve dependencies

Now, i have a project which runs fine on my windows computer. But after I copied it to a linux computer, when compiling it reports following error:
Failed to execute goal on project alert: Could not resolve dependencies for project com.cloud.ras:alert.
The POM for com.external:commons-logging:jar:1.0.4.1 is missing, no dependency information available
The POM for com.external:freemarker:jar:2.3.4 is missing, no dependency information available
The POM for com.external:log4j:jar:1.2.14 is missing, no dependency information available
The POM for com.soa.lib:eBoxServiceCommon:jar:2.5.3 is missing, no dependency information available
but i have copied these jars to the maven repository. And can anyone give me a help?
You should NOT copy JARs in the first place. That's Maven job to resolve the dependencies for you.
It would be helpful if you explain the reason why you need to use your own groupId e.g. com.external in the first place i.e. commons-logging is from Apache but you use com.external as its groupId.
If you really insist on wanting to use your own groupId, at least download the JAR and install it using Maven. See here:
http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html.

How to find out which maven artifact/plugin is requesting for the download of a no longer available dependency

I was compiling an "old" open sourced project, while encountered this problem:
[ERROR] Failed to execute goal on project .... Can not transfer artifact x:y:z from ...
the artifact x:y:z is not found from all repositories defined in the project pom.xml.
After looked up the effective pom.xml, I could not find any references to x:y:z.
How can I find out which artifact or plugin is requesting a missing dependency without analyze all transitive dependencies?
If you use eclipe - you can see dep tree like this: open pom.xml and tick "Dependency Hierarchy" tab.
Also you can try to use mvn dependency:tree but I am not totally sure that it will work if some of your deps are missing.
UPDATE: seems like both eclipse and dependency:tree require sucessfull artifact resolution to work whch is not your case.
In this case I guess you're left with 3 opttions:
clean your cache (wipe everything under ~/.m2/repository), run your build and do occurence search (search for something like "problematic-artifact-id") on files in your ~/.m2/repository. One or couple of the artifacts should reference the problematic artifact in their pom. This should give you a hint.
clean your cache and run your build with -X switch. This will put maven in verbosity mode and you should find some hints about what might reference dead dependency (point your attention on download order, what artifacts got resolved, check dependencies of resolved artifacts in their poms)
dumb as hell - comment/uncomment deps in your pom and see what causes the mentioned error.

Maven POM error - POM is missing

I am trying to build a maven project. My other team members are able to build it without issues. I get the following errors:
[WARNING] The POM for org.hectorclient:hector-core:jar:1.0-3 is missing, no dependency information
available
[WARNING] The POM for org.hectorclient:hector-test:jar:1.0-3 is missing, no dependency information
available
Then the build fails with the error: Could not resolve dependencies for the project XYZ. What could be possibly going wrong?
Surely the jar is missing from your .m2 local repository.
Assuming the dependency is written in the pom.
What I suggest:
Case: When you have internet
fire mvn install that will follow your POM.xml and it will download all the necessary jars.
then fire mvn compile to build.
Case: You are having restricted internet connection that is restricting / no Internet
Take the repository + POM from other machine that is compiling successfully
then fire mvn -o compile
I assume it will solve your case.
#Vaibs You are correct. Adding to your answer:
"Check the settings.xml of yours and the others. If you are not able to download the dependencies from internet like the one you mentioned due to some reason then you will need to set up maven somewhere else and and fire "mvn install" there to get the latest dependencies and put those .m2 into yours."

Maven dependency hell - previously removed repository appears during my build

Our project used to have a repository that now is deprecated jboss - hibernate bug explained here, we updated every single pom we had with the new repository, and it seemed to work just fine until today, when I decided to checkout the project and do a clean build into a new machine.
Now, I've got maven complaining that it can't reach the old repository. I've grepped the whole filesystem checking for the culprit and couldn't find it. But still I've got this
Failed to read artifact descriptor for org.jboss.aop:jboss-aop:jar:2.0.0-SNAPSHOT: Could not transfer artifact org.jboss.aop:jboss-aop:pom:2.0.0-SNAPSHOT from/to jboss (http://repository.jboss.com/maven2): Access denied to: http://repository.jboss.com/maven2/org/jboss/aop/jboss-aop/2.0.0-SNAPSHOT/jboss-aop-2.0.0-SNAPSHOT.pom -> [Help 1]
I have no idea what's going on, my theory (besides that this could be an x-file) is that other dependency somehow managed to include this repo? Am I right? How can I check this?
I tried to build the dependency tree (mvn dependency:tree) to see who is the one that tries to include it, but since the whole project can't build I can't get the dep:tree ~grin~
Can anybody explain me what exactly is wrong here? how can I debug it? "BTW -e option doesn't bring any other useful info, still I pasted it below for any eagle-eye expert out there :)"
So far, I've started to copy the whole ~/.m2/repository from other machine to the new one, hopefully this will make the trick. But still, I was expecting maven to download and build the project from scratch as it's supposed to do
Here is the stacktrace
Caused by: org.sonatype.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.jboss.aop:jboss-aop:jar:2.0.0-SNAPSHOT
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:282)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:172)
at org.sonatype.aether.impl.internal.DefaultDependencyCollector.process(DefaultDependencyCollector.java:419)
at org.sonatype.aether.impl.internal.DefaultDependencyCollector.process(DefaultDependencyCollector.java:533)
at org.sonatype.aether.impl.internal.DefaultDependencyCollector.process(DefaultDependencyCollector.java:533)
at org.sonatype.aether.impl.internal.DefaultDependencyCollector.process(DefaultDependencyCollector.java:533)
at org.sonatype.aether.impl.internal.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:243)
... 25 more
Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Could not transfer artifact org.jboss.aop:jboss-aop:pom:2.0.0-SNAPSHOT from/to jboss (http://repository.jboss.com/maven2): Access denied to: http://repository.jboss.com/maven2/org/jboss/aop/jboss-aop/2.0.0-SNAPSHOT/jboss-aop-2.0.0-SNAPSHOT.pom
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:541)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:220)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:197)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:267)
... 31 more
Caused by: org.sonatype.aether.transfer.ArtifactTransferException: Could not transfer artifact org.jboss.aop:jboss-aop:pom:2.0.0-SNAPSHOT from/to jboss (http://repository.jboss.com/maven2): Access denied to: http://repository.jboss.com/maven2/org/jboss/aop/jboss-aop/2.0.0-SNAPSHOT/jboss-aop-2.0.0-SNAPSHOT.pom
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:949)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:940)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.flush(WagonRepositoryConnector.java:695)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.flush(WagonRepositoryConnector.java:689)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector.get(WagonRepositoryConnector.java:445)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:460)
... 34 more
Caused by: org.apache.maven.wagon.authorization.AuthorizationException: Access denied to: http://repository.jboss.com/maven2/org/jboss/aop/jboss-aop/2.0.0-SNAPSHOT/jboss-aop-2.0.0-SNAPSHOT.pom
at org.apache.maven.wagon.providers.http.LightweightHttpWagon.fillInputData(LightweightHttpWagon.java:119)
at org.apache.maven.wagon.StreamWagon.getInputStream(StreamWagon.java:116)
at org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:88)
at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.run(WagonRepositoryConnector.java:608)
at org.sonatype.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:64)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Thanks in advance
UPDATE 08/10/2011
Seems that the problem is related to maven3. Last update from apple pushed some java changes including maven3. After download and set up maven2 and perform a full "mvn clean compile build" problem disappeared.
I'll update this thread when I've got more info on the issue
Thanks to everybody that answered and gave ideas. Your help is very much appreciated.
Instead of a dependency tree, use
mvn help:effective-pom
and search the output of that for the repo. If a multi-module build, make sure to run it at the top level to get all the poms at once. If it's not mentioned there, double check ~/.m2/settings.xml and $M2_HOME/conf/settings.xml for it. It's definitely somewhere in your file system. Maven doesn't just magically add repos.
If you use Eclipse, M2Eclipse's Dependency Graph is an alternative to dependency:tree which might work without requiring Maven to run against the POM.
When looking at dependency POMs for repos, you also need to look at parents/ancestors of those POMs.
Perhaps you should relook at the specified dependency - org.jboss.aop:jboss-aop:jar:2.0.0-SNAPSHOT. It looks like does not exist in jboss repository. You could try 2.0.0.GA instead.
You "updated every single pom ... with the new repository"? Don't put repositories in your poms.
http://www.sonatype.com/people/2009/02/why-putting-repositories-in-your-poms-is-a-bad-idea/
I suspect Maven is trying to hit that repo because it is being referenced in the pom of a transitive dependency (Maven 3 uses slightly different dependency resolution than Maven 2), or else there may be something in the compatibility notes about repositories that is affecting you.

Resources