Maven not picking locally installed dependency - maven

I downloaded and imported a multi-module maven project say Project-A. In installed one of its modules say moduleA1 into my local repository and I can see it in the repository directory.
I created another Project-B which has moduleA1 as a dependency. But when I try to package Project-B, I notice that maven is searching for moduleA1 in the online central repository and it fails.
This is the error I get:
[ERROR] Failed to execute goal on project <project-B>: Could not resolve dependencies for project <Project-B>:war:1.0: Failed to collect dependencies at <moduleA1>:jar:<version>: Failed to read artifact descriptor for <moduleA1>:jar:<version>: Failure to find <moduleA1-groupId>:<moduleA1>:pom:<version> in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
How can I make maven to resolve this moduelA1 dependency from my local repository.

This problem can occur if you have some child projects that refer to a parent pom (moduleA1 in your case) and you have not installed from the parent pom directory (run mvn install from the parent directory (i.e. Project-A in your case)). If one of the child projects (moduleA1 in your case) may depend on a sibling project (let's assume you have another module moduleA2) and when it goes to read the pom of the sibling, it will fail with the error mentioned in the question unless you have installed from the parent pom directory at least once. So just try running:
mvn -U clean install
from your Project-A directory

Maven automatically resolves dependencies from the local repository.
Without the exact error message, it is difficult to give a more precise answer.

Related

Q: “the pom for XXX is missing, no dependency information available”,but the dependency is already in the Nexus repository

while running mvn packaging, there is a warming shown in log.
[WARNING] The POM for com.yueyue:order-search-interface:jar:1.2.1.SNAPSHOT is missing, no dependency information available
and the compiling is failed in the end with the error as following.
[ERROR] Failed to execute goal on project dispatch-admin: Could not resolve dependencies for project com.yueyue:dispatch-admin:jar:2.0.0-SNAPSHOT: Could not find artifact com.yueyue:order-search-interface:jar:1.2.1.SNAPSHOT in bailongma_repo2 (http://192.168.200.224:8081/repository/bailongma_repo2/) -> [Help 1]
but the dependency is already in the maven-snapshots which is in the "bailongma_repo2" group repo.
by the way, this dependency is also in a remote repo which is as a proxy repo "aliyun_snapshot2" in "bailongma_repo2" group repo. the structure of "bailongma_repo2" group repo is as following.
what should i check first for this problem? many thanks in advance!

Netbeans 8.2 Maven java fx error in building project

I worked on netbeans 8.2 so there when i create a project on maven -javafx the project does not buiilt it gives the following error.
Failed to execute goal org.apache.maven.plugins:maven-archetype-
plugin:3.0.1:generate (default-cli) on project standalone-pom:
Execution default-cli of goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate failed:
Plugin org.apache.maven.plugins:maven-archetype-plugin:3.0.1
or one of its dependencies could not be resolved:
The following artifacts could not be resolved: org.codehaus.groovy:groovy:jar:1.8.3,
org.apache.ant:ant:jar:1.8.1:
Could not transfer artifact org.codehaus.groovy:groovy:jar:1.8.3 from/to central
(http://repo.maven.apache.org/maven2): repo.maven.apache.org: Unknown host repo.maven.apache.org -> [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.
A picture is also attached please help me solve this problem.picture of the problem
It appears you cannot reach the maven repository to download the dependencies!
see This question it helps find out which is the problem.
The url http://repo.maven.apache.org/maven2 you are using is it correct?
Can you reach this address from the machine on which you run the maven build?

Spring MVC issues in STS 3.7.3

I am getting this error on importing https://github.com/spring-projects/spring-mvc-showcase in STS 3.7.3:---
Description Resource Path Location Type
Failure to transfer org.codehaus.mojo:aspectj-maven-plugin:pom:1.2 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.codehaus.mojo:aspectj-maven-plugin:pom:1.2 from/to central: connect timed out pom.xml /spring-mvc-showcase line 1 Maven pom Loading Problem
Edit
Mvn is ok now but pom.xml error still persists if I remove the errors and do maven clean I get errors as:
[INFO] https://repo.maven.apache.org/maven2/org/codehaus/mojo/aspectj-maven-plugin/1.2/aspectj-maven-plugin-1.2.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [ERROR] Plugin org.codehaus.mojo:aspectj-maven-plugin:1.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:aspectj-maven-plugin:jar:1.2: Could not transfer artifact org.codehaus.mojo:aspectj-maven-plugin:pom:1.2 from/to central: connect timed out -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
First of all STS is build on Eclipse. So you can easily install the IDE Integration Eclipse IDE - M2Eclipse for STS. You can see how here. If you want to use it with this integration plugin you dont need to have a local maven repository.
Resolving Maven dependencies from the Eclipse workspace without installing to local Maven repository
But its also possible to use maven as a local system repository. Download is here and follow the steps for the installation and configuration here.
To see if you have a valid maven installation done, you can test it by typing mvn -v in a cmd shell or using STS -> right click on your project -> run as -> maven build or maven install.
Update:
I would say delete the project from your workspace and try it again. Download the project from gitHub as a zip file and import it again to your workspace. Right Click -> import -> existing maven project.
If you need to use a proxy for your connection you have to create a settings.xml in your .m2 folder. Look here for more info

How to determine which Maven dependency is needing a missing dependency?

I am trying to build an old Maven project and I'm getting the error:
[ERROR] Failed to execute goal on project myapp: Could not resolve dependencies for project com.initech.myapp:war:${buildVersion}: Failure to find tangosol:tangosol-coherence:jar:3.3-rc1 in http://mvnrepo.initech.com/archiva/repository/initechrepo was cached in the local repository, resolution will not be reattempted until the update interval of initechrepo has elapsed or updates are forced -> [Help 1]
I looked in the pom.xml of MyApp and there is no mention of "tangosol" and there is no parent POM so I figure this must be a transitive dependency.
Normally, I can use the Maven Dependency plugin on the command line with mvn dependency:tree to display transitive dependencies. However, since the dependency is missing, the build fails and errors out instead of displaying the tree.
How can I get the cause of missing transitive dependency even if the build is failing?
EDIT: I am aware of why it failed, the artifact is missing from our local repository and the central repository, the question is which of my dependencies is asking for it.
There should be a better way, but if you run the command in debug mode (ie -X so the full command becomes mvn -X dependency:tree) then you'll see the trace printed out before the build dies:
...
[DEBUG] org.springmodules:spring-modules-cache:jar:0.9:compile
[DEBUG] opensymphony:oscache:jar:2.3:compile
[DEBUG] tangosol:tangosol-coherence:jar:3.3-rc1:compile
[DEBUG] oro:oro:jar:2.0.8:compile
[DEBUG] org.apache.jcs:jcs:jar:1.3:compile
[DEBUG] concurrent:concurrent:jar:1.0:compile
...
better answers are welcome.
I am wondering why maven didn't download the required dependency from the MAVEN CENTRAL REPO , if it is not available in your local repository.
mvn dependency:tree is useful to see the hierarchy , that means it can tell you which jar will depend on which others jars.
So, what i can guess from here is that required jar tangosol-coherence is missing in your internal nexus repository. i.e
http://mvnrepo.initech.com/archiva/repository/initechrepo
So, to overcome this problem either you have to install the required jar in your internal nexus repository or as a temporary solution you can download that jar and put it into your local system repository, so that you can have a successful build.
Thanks

What is the correct way to place this JAR in my local repo?

I'm using Maven 3.0.3. Evidently, the Oracle JDBC drivers are not available in a public Maven repo, so I'm reduced to installing it to my local one. So I created this file
~/.m2/repository/oracle/oracle/10.2.0.3.0/classes12.jar
I have this in my pom.xml file …
<dependency>
<groupId>oracle</groupId>
<artifactId>classes12</artifactId>
<version>10.2.0.3.0</version>
</dependency>
Yet upon running maven, I'm getting this error. How do I structure my local repo? - Dave
[ERROR] Failed to execute goal on project infinitiusa_leads_testing: Could not resolve dependencies for project infinitiusa_leads_testing:infinitiusa_leads_testing:jar:1.0-SNAPSHOT: Failure to find oracle:classes12:jar:10.2.0.3.0 in http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
First of all, you must install the file in the repository, not only copy it to the right directory. See the answer: Find Oracle JDBC driver in Maven repository.
Secondly, the directory is actually not right. For the dependency you provided in pom.xml it should lie in:
~/.m2/repository/oracle/classes12/10.2.0.3.0/classes12-10.2.0.3.0.jar
But this is taken care of by install:install-file, don't manipulate the repository directory manually (except deleting some stuff, maven sometimes gets confused and it needs restart, but that's a different story).
mvn install:install-file -DgroupId=oracle -DartifactId=classes12 \
-Dversion=10.2.0.3.0 -Dpackaging=jar -Dfile=classes12.jar
BTW consider com.oracle as groupId.
Also maven typically gives the very exact command line you should run to install the missing dependency in your local repository. Don't know why it didn't happen in your case.

Resources