Connection timed out :connect error while downloading from Nexus in Maven - maven

I want only single command to download from Nexus. I also tried using copy goal instead of get.
I am using the following command to download from Nexus:
mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get -DremoteRepositories=url -Dartifact=groupId:ArtifactId:Version -Dhttps.protocols=TLSv1.2
But i am getting a timeout error and trying to download from central, not from my remote repository.
What changes do i need to do in settings.xml?

See here for instructions on setting up Maven to work with Nexus Repo: https://help.sonatype.com/display/NXRM3/Maven+Repositories#MavenRepositories-ConfiguringApacheMaven

check whether your network/firewall is blocking such request, there is a high possibility of firewall blocking access of maven repository location.
generic setting.xml looks like,
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository/>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups/>
<servers/>
<mirrors/>
<proxies/>
<profiles/>
<activeProfiles/>
</settings>
Check MAVEN_HOME and M2_HOME in enviroment variable of setup of your local machine's maven home

Related

How to move maven directory ".m2" from my home directory after installing IntelliJ

I've just installed IntelliJ 15 on Ubuntu and wanted to update maven repository indices, I am having disk space errors because my home folder is on a limited size partition.
I am totally lost trying to move ~/.m2 to somewhere else. I've tried IntelliJ settings and changed paths and maven settings but didn't work and most of the time they return to the home folder after restarting IntelliJ.
I wanted to add that I didn't install maven (using apt-get install maven). Would this help or give more control?
You can modify the location of the Maven local repository by modifying the Maven settings. From Configuring your Local Repository:
The location of your local repository can be changed in your user configuration. The default value is ${user.home}/.m2/repository/.
<settings>
...
<localRepository>/path/to/local/repo/</localRepository>
...
</settings>
Note: The local repository must be an absolute path.
Since you are using the Maven installation that is shipped with IntelliJ and not your own Maven version, you can create a Maven user settings:
Create a file settings.xml under ${user.home}/.m2/
Have the following content in it:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>/path/to/local/repo</localRepository>
</settings>
Maven will read this file and use the specified local repository.
Another alternative I found is also by eclipse itself.
Create the setting.xml file in my D:\TAAS\settings.xml directory as follows:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>D:\TAAS\.m2\repository</localRepository>
</settings>
Then I configured it by the eclipse itself according to the following figure.
This is an option for maven embedded versions.

mvn clean install throwing build failure error

I am new to maven. I recently cloned a repository from GIT and saved it in a location on my machine. I have git bash, i am cd'ing to the location where i saved my code and trying to execute the mvn clean install command. but i am seeing the below error. It is unable to locate POM files. How can I solve this problem?. I have tried deleting the code and cloning again but that has not helped.
Below is the POM file:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.XXXX</groupId>
<artifactId>XXX-XXX</artifactId>
<version>sprint1506-SNAPSHOT</version>
<packaging>pom</packaging>
<name>XXX-XXX</name>
<url>http://maven.apache.org</url>
<description>
This is the Mega pom to combine XXX, XXX
and XXX projects in a single reactor.
</description>
<modules>
<module>wesp</module>
<module>transite</module>
<module>sassy</module>
</modules>
</project>
Solution 1 : Build it by your own
As OhadR said, your local repository does not contain the jasmine-maven-plugin, so :
Clone the jasmine-maven-plugin repo (git clone git#github.com:searls/jasmine-maven-plugin.git)
Build this plugin with mvn installcommand
Build the project you cloned with mvn install command
Solution 2
If you don't want to rely on your own build, try to add the Sonatype repository to your pom, as an external source. Looking at the plugin jasmine-maven-plugin's pom, it appears that they deploy it on OSS repo.
<project ...>
<repositories>
<repository>
<id>OSS</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
</repositories>
</project>
The problem was fixed when i updated the settings.xml file in apache-maven-3.3.3\conf folder. I had to configure my login credentials in the settings.xml file for the build to complete. I also had to point my .m2/repository directory to the <localRepository> tag inside the settings.xml file for the build to commence. Thanks everyone for the inputs.
Below are the fields which I changed inside the settings.xml file ( highlighted in bold):
****<localRepository>C:\Users\XXX\.m2\repository</localRepository>****
<proxies>
<proxy>
<id>XXXX</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.kdc.XXXXX.com</host>
<port>8099</port>
**<username>XXX</username>**
**<password>XXXX</password>**
<nonProxyHosts>*.XXXXX.com</nonProxyHosts>
</proxy>
</proxies>

No plugin found for prefix 'install' in the current project

I want to add jdbc oracle to maven repository since it is not in repository, I have to run this command:
mvn install:install-file
-Dfile=D:\Temp\ojdbc6.jar
-DgroupId=com.oracle
-DartifactId=ojdbc6 -
Dversion=11.2.0 -Dpackaging=jar
and run into this error:
[ERROR] No plugin found for prefix 'install' in the current project and in the p
lugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the re
positories [local ({my repository path}), central (https://repo.maven.
apache.org/maven2)]
any help would be appropriated.
I recently got the same error and I tried this command. It worked.
export MAVEN_OPTS=-Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2
I have faced the same issue, there is a two-step process to resolve this issue:
Configure Maven Proxy Configuration
Open Maven configuration file:
For Linux: ${user.home}/.m2/settings.xml
For Windows: C:\users\username\.m2\settings.xml
If you could find the file open it and search for <proxies></proxies> the segment.
If you cannot find the file, create a new file called settings.xml and add following xml tags <settings></settings>
Add the proxy configurations as below:
<proxies>
<proxy>
<id>example-proxy</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.example.com</host>
<port>8080</port>
<username>proxyuser</username>
<password>somepassword</password>
<nonProxyHosts>www.google.com|*.example.com</nonProxyHosts>
</proxy>
</proxies>
Update Maven Libraries with a Working Extension
Wagon HTTP lightweight library allows us to connect through NTLM proxies. This can be added as an extension to default Maven libraries.
Download the wagon-http-lightweight-2.2.jar from
https://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-http-lightweight/2.2/wagon-http-lightweight-2.2.jar
Copy the downloaded file to %M2_HOME%/lib/ext folder.
Now you are ready to use Maven with your programs.
Try adding this to your Maven configuration file:
<!-- https://mvnrepository.com/artifact/com.oracle/ojdbc14 -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.4.0</version>
</dependency>
It should install Oracle JDBC to your repository and should install the necessary JARS.
https://www.tech-recipes.com/rx/39256/add-dependencies-to-maven-pom-xml-file/
Add it within the dependencies tag.
Hope it helps!
[ERROR] No plugin found for prefix ‘install’ in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/amitkumar/.m2/repository), central (https://repo.maven.apache.org/maven2)]
There are 2 steps we need to follow to fix this issues :
Step 1 : Open Maven configuration file: For Linux: ${user.home}/.m2/settings.xml
If you could find the file open it and search for the segment.
If you cannot find the file, create a new file called settings.xml and add following xml tags
Add the proxy configurations as below:
<settings xmlns="http://maven.apache.org/settings/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>www-proxy.us.oracle.com</host>
<port>80</port>
<nonProxyHosts>adc2170275|*.oracle.com|*.oracleads.com|*.us.oracle.com|
*.uk.oracle.com|*.ca.oracle.com|*.oraclecorp.com|
*.oracleportal.com
</nonProxyHosts>
</proxy>
</proxies>
</settings>
Step 2:
Update Maven Libraries with a Working Extension
Wagon HTTP lightweight library allows us to connect through NTLM proxies. This can be added as an extension to default Maven libraries.
Download the wagon-http-lightweight-2.2.jar from https://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-http-lightweight/2.2/wagon-http-lightweight-
2.2.jar
Copy the downloaded file to %M2_HOME%/lib/ext folder.

mvn stops working on downloading

when i try to run
mvn clean install
(or such a command of maven)
then he starts to download the dependency.
At one dependency (one on our server) he stops and don't continue to work.
More poeple says that this can be a problem of antivirus or firewall.
I tryed to made a
scp address#myrepo:.....
and it works. This for my opinion is not a firewall problem or antivirus (I run on ubuntu, and don't have any antivirus installed)
Can some one give me some tips how figure out the problem?
Maven version 3.2.1
I have noticed this behavior: When it start the download a directory under .m2/repository/.... is created. In the directory 2 file are created:
-nameOfPom.pom.lastUpdated
-nameOfPom.pom.tmp4c338b26031e4cda
When I open the first file I can see:
Cannot connect. Reason\: java.net.ConnectException\: Connection timed out
An other info:
On the server side I see that a connection is established.
I found the problem:
I installed the maven version 3.0.4 and now all works!
Make sure your private/enterprise repo is configured in your local maven settings.
In the $MAVEN_HOME/conf/settings.xml file, you should add :
<settings ...>
...
<servers>
...
<server>
<id>private-repo</id>
<username>{REPO_USER}</username>
<password>{REPO_PASS}</password>
</server>
</servers>
<mirrors>
...
<mirror>
<id>private-repo</id>
<mirrorOf>*</mirrorOf>
<url>http://...</url>
</mirror>
</mirrors>
...
</settings>

How to create a Maven "Project Repo"

I've been asked to look at an old project that requires Maven 2.1 and a couple JARs that are not (and will not) stored in our Nexus.
I'm trying to follow the advice from #Nikita Volkov in this post about creating a project repo to hold the JARs as artifacts. The idea being I can check this repo into source control. I can then check it out on any machine and have it build without any special configuration.
To start with I've created a repo and added my first Jar to it by running:
mvn install:install-file -DlocalRepositoryPath=repo -DcreateChecksum=true -Dpackaging=jar -Dfile=lib/myJar.jar -DgroupId=my.group -DartifactId=myArtifact -Dversion=0.0.1
I then create POM that looks like:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>my.group</groupId>
<artifactId>MyApp</artifactId>
<packaging>ear</packaging>
<version>1.0-SNAPSHOT</version>
<repositories>
<repository>
<id>my-repo</id>
<url>file://${project.basedir}/repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>my.group</groupId>
<artifactId>myArtifact</artifactId>
<version>0.0.1</version>
</dependency>
</dependencies>
<build>
</build>
</project>
When I view this in Eclipse if flags the dependency with error
Missing artifact my.group:myArtifact:jar:0.0.1.
When I run it from the command line Iget the error
Unable to find resource 'my.group:myArtifact:pom:0.0.1' in repository my-repo
Clearly I've not understood something in the original post, but I don't see what
So, can anybody provide a working example of how to create a in-project Maven Repo?
Update
The files stored in my local repo are:
my/group/myArtifact/0.0.1/myArtifact-0.0.1.jar
my/group/myArtifact/0.0.1/myArtifact-0.0.1.jar.md5
my/group/myArtifact/0.0.1/myArtifact-0.0.1.jar.sha1
my/group/myArtifact/0.0.1/myArtifact-0.0.1.pom
my/group/myArtifact/0.0.1/myArtifact-0.0.1.pom.md5
my/group/myArtifact/0.0.1/myArtifact-0.0.1.pom.sha1
my/group/myArtifact/maven-metadata-local.xml
my/group/myArtifact/maven-metadata-local.xml.md5
my/group/myArtifact/maven-metadata-local.xml.sha1
Update
The contents of my .m2/settings file is:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://192.168.152.78:5000/nexus/content/groups/public/</url>
</mirror>
</mirrors>
</settings>
Working solution after several updates to the original question
Your settings.xml file declares a catch-all mirror. This takes effect over the local repository declaration in your pom file. Either remove the catch-all mirror, or try excluding the repository ID of your project repository from the mirroring:
<mirror>*,!my-repo</mirror>
Original answer
Looks like you install the library to the default local Maven repository location (~/.m2/repository), but then you try to pick it up from a location within your project.
Try changing the repository location for Maven before you run the "mvn install:install-file" goal. You can do this by adding a "localRepository" setting in your settings.xml.
You could also create a new settings.xml specifically for your project and tell Maven to use that whenever you work on your project (-s parameter on the command line). IDEs like Eclipse or IntelliJ also support using an alternative settings.xml file.

Resources