Maven deploy error - maven

I have maven project with several modules. Need to deploy all modules(jars and one resulting war) into remote Artifactory server.
So in settings.xml I am added config:
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
<username>admin</username>
<password>password</password>
<id>central</id>
</server>
<server>
<username>admin</username>
<password>password</password>
<id>snapshots</id>
</server>
</servers>
<profiles>
<profile>
<repositories>
<repository>
<id>central</id>
<name>libs-release</name>
<url>http://192.168.1.120:8088/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://192.168.1.120:8088/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://192.168.1.120:8088/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://192.168.1.120:8088/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
Main pom have section:
<distributionManagement>
<repository>
<id>central</id>
<url>http://192.168.1.120:8088/artifactory/libs-release-local</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://192.168.1.120:8088/artifactory/libs-snapshot-local</url>
</snapshotRepository>
</distributionManagement>
And all modules have 1.0-SNAPSHOT version.
But when executing the command: >mvn deploy, the Following error occured:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy
(default-deploy) on project jobic: Failed to deploy artifacts: Could
not transfer artifact *project-name:project-nam*e:pom:0.0.1 from/to central
(http://192.168.1.120:8088/artifactory/libs-release-local): Failed to
transfer file:
http://192.168.1.120:8088/artifactory/libs-release-local/project-name/project-name/0.0.1/project-name-0.0.1.pom.
Return code is: 401 -> [Help 1]
How to deal with it?
UPDATE:
Ok, I got it. The 401 error says: 401 = "Unauthorized" . So I added proper username/password into settings.xml. Seems work now.
Have one last question: it is right, that I am using SNAPSHOT suffix in the version? Is it proper behavior for situation, when I need do deploy all modules onto remote repo? How to deal with situation, when the one module was broken and my coworkers need to use previous version of this module?

It might be because it is written incorrectly.
You can change it hhttp to http and try again.

Related

Maven Bnd Repository Plugin fails to fetch artifact from remote artifactory

I'm trying to get bnd tools structure working (started with tutorial https://bndtools.org/tutorial.html)
Added use of javax.vecmath (as simple library as I could think of) in cnf/central.maven file
javax.vecmath:vecmath:1.5.2
and added it to build path in org.example.impl with everything resolving just fine.
I have fork of this library in jFrog artifactory running on remote server, so next step was defining that repository in cnf/build.bnd adding (as described in https://bnd.bndtools.org/plugins/maven.html)
-plugin.10.Remote = \
aQute.bnd.repository.maven.provider.MavenBndRepository; \
releaseUrl=https://artifactory.website.com/artifactory/libs-release-local/; \
snapshotUrl=https://artifactory.website.com/artifactory/libs-snapshot-local/; \
index=${.}/release.maven; \
name="Maven Remote"
and appropriate reference in cnf/release.maven
javax.vecmath:vecmath:2.1.5
When adding this library to build path I get error "2.1.5 [Could not fetch javax.vecmath:vecmath:2.1.5]" with no further information.
I figured the only difference between maven central and my artifactory should be content of .m2/settings.xml with credentials (according to https://bnd.bndtools.org/instructions/connection-settings plugin should look there in the first place).
Configuration that works for maven in eclipse (when I open a maven project that has vecmath 2.1.5 as dependency it gets pulled without a problem to .m2/repository/javax/vecmath/vecmath/2.1.5 and once there it gets resolved just fine by bnd)
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
<username>username</username>
<password>roigonsdnglosgnoisfgnsdjgnlafjksasgnl</password>
<id>central</id>
</server>
<server>
<username>username</username>
<password>roigonsdnglosgnoisfgnsdjgnlafjksasgnl</password>
<id>snapshots</id>
</server>
</servers>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>https://artifactory.website.com/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>https://artifactory.website.com/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>https://artifactory.website.com/artifactory/libs-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>https://artifactory.website.com/artifactory/libs-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
From this it seems bnd has no problem fetching from maven central to local m2 repository and using it from there, but fails to connect to my artifactory. Is there some key setting or difference I'm missing?
Ended up solving the issue with help from https://groups.google.com/forum/#!forum/bndtools-users having found two (three?) problems with my configuration.
The correct form for repository definition in build.bnd seems to be
-plugin.10.Remote: \
aQute.bnd.repository.maven.provider.MavenBndRepository; \
releaseUrl=https://artifactory.website.com/artifactory/libs-release-local/; \
snapshotUrl=https://artifactory.website.com/artifactory/libs-snapshot-local/; \
index=${.}/release.maven; \
name="Maven Remote"
Looking in https://bnd.bndtools.org/instructions/connection-settings server auth configuration for bnd differs from maven configuration (0.3.4, for some reason I missed that part)
<server>
<username>username</username>
<password>roigonsdnglosgnoisfgnsdjgnlafjksasgnl</password>
<id>https://*website.com</id>
</server>
and bnd is looking for connection settings first in .bnd, if there are none, then in .m2, but if there are incorrect/insufficient settings in .bnd it does not look in .m2 even if it contains correct/sufficient ones.
The default order in which bnd looks for settings is:
`~/.bnd/connection-settings.xml`
`~/.m2/settings.xml`

How to set up maven?

How to set up Maven (settings.xml) and Artifactory to access all repositories through Artifactory?
My current settings are as follows and I even fail to get the Maven-deploy plugin
to execute. The error is that it was not found in any repos (local + artifactory)
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
<username>xxx</username>
<password>xxx</password>
<id>central</id>
</server>
<server>
<username>xxx</username>
<password>xxx</password>
<id>snapshots</id>
</server>
</servers>
<mirrors>
<mirror>
<mirrorOf>*</mirrorOf>
<name>repo</name>
<url>http://[host]:[port]/artifactory/repo</url>
<id>repo</id>
</mirror>
</mirrors>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://[host]:[port]/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://[host]:[port]/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://[host]:[port]/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://[host]:[port]/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
[host]:[port] are real in file and so is [username][password] checked that 3 times.
[ERROR] No plugin found for prefix 'deploy' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\[username]\.m2), repo (http://[host]:[port]/artifactory/repo)] -> [Help 1]
Artifactory can generate the right settings.xml file for you. Look for Maven Settings link on the right side menu of the home screen.

Using Nexus repository instead of public Maven in Idea Intellij

How can I force Idea Intellij to download from Nexus repository instead of Maven Public repo?
Where can I configure that in Idea properties?
It's not defined in pom.xml files and I'd prefer not to.
Not sure if it will work also on Idea Intellij ( I am using spring source studio - eclipse clon) , but should because maven configuration is in settings.xml in .M2 directory which is located in your home directory. Just use something like this ( my server is running on nexus-server:8081):
<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">
<servers>
<server>
<id>releases</id>
<username>user-name</username>
<password>your-password</password>
</server>
<server>
<id>snapshots</id>
<username>user-name</username>
<password>your-password</password>
</server>
</servers>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://nexus-server:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Disable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>

How to disable usage of public maven repo

I've setup a maven repository(Artifactory) in my LAN which has no internet access. I've also change my maven settings.xml to use this internal repo only. However when I try to create a maven project, it still try to access the public repo(http://repo1.maven.org/maven2) for some downloads. Where has I done wrong?
For example, when I perform the following:
mvn archetype:generate -DgroupId=demo.john -DartifactId=struts2demo
-DarchetypeGroupId=org.apache.struts
-DarchetypeArtifactId=struts2-archetype-starter
-DinteractiveMode=false
there is the following waring reported:
... ...
[INFO] Generating project in Batch mode
[WARNING] Error reading archetype catalog http://repo1.maven.org/maven2
org.apache.maven.wagon.TransferFailedException: repo1.mavne.org
at org.apache.maven.wagon.shared. ...
... ...
Sometimes the it build successfully with this waring, but sometime it won't.
Below is my maven's settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
<id>central</id>
<username>admin</username>
<password>password</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>password</password>
</server>
</servers>
<mirrors>
<mirror>
<id>my-company-repo</id>
<name>A maven repo in local network</name>
<url>http://my.internal.server/artifactory/repo<url>
</mirror>
<mirrorOf>*</mirrorOf>
</mirrors>
<profiles>
<profile>
<id>artifactory</id>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://my.internal.server/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://my.internal.server/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://my.internal.server/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://my.internal.server/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>

Maven. Repository authentication

I tried setup deploy to local repository:
-- settings.xml --
<server>
<id>myrepo</id>
<username>deployer</username>
<password>123456</password>
</server>
-- pom.xml ---
<repositories>
<repository>
<id>myrepo</id>
<url>http://myserver.com/artifactory/libs-release-local</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
when I execute "mvn deploy" I got error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.4:
deploy (default-deploy) on project xxx: Failed to deploy artifacts: Co
uld not transfer artifact xxx:xxx:war:0.1-20130527.121430-3 from/to myserver.com
(http://myserver.com:8083/artifactory/libs-snapshot-local): Failed to transfer file:
http://myserver.com:8083/artifactory/libs-snapshot-local/xxx/0.1-SNAPSHOT
/xxx-0.1-20130527.121430-3.war. Return code is: 401
Artifactory log:
2013-05-27 16:14:38,158 [DENIED DEPLOY] libs-snapshot-local:xxx/0.1-SNAPSHOT
/xxx-0.1-20130527.121430-3.pom for anonymous/192.168.6.36.
If I change server/repository id to "myserver.com" - deploy WORK!
But it does not suit me because that did not work plugin changelog with svn at myserver.com
I tried to add tags "profile" and "mirror" to server.xml and "distributionManagement" to pom.xml - getting the same error
server/repository id must be named ONLY as my server?
UPDATE1:
I remove tag 'repositories' from pom.xml and added tag 'distributionManagment':
--- pom.xml ---
<distributionManagement>
<repository>
<id>myrepo</id>
<name>myrepo</name>
<url>http://myserver.com/artifactory/libs-release-local</url>
</repository>
<snapshotRepository>
<id>myrepo</id>
<name>myrepo</name>
<url>http://myserver.com/artifactory/libs-snapshots-local</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
</distributionManagement>
(server.xml has not changed) - getting the same error "Failed to deploy..."
UPDATE2:
Try...
--- server.xml ---
<profiles>
<profile>
<id>artifactory</id>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://myserver.com/artifactory/libs-release-local</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://myserver.com/artifactory/libs-snapshot-local</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
<server>
<id>snapshots</id>
<username>deployer</username>
<password>123456</password>
</server>
<server>
<id>central</id>
<username>deployer</username>
<password>123456</password>
</server>
--- pom.xml ---
<distributionManagement>
<repository>
<id>central</id>
<name>Internal Releases</name>
<url>http://myserver.com/artifactory/libs-release-local</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Internal Snapshots</name>
<url>http://myserver.com/artifactory/libs-snapshots-local</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
</distributionManagement>
execute 'mvn deploy' - again error :(
Failed to deploy artifacts: Could not transfer artifact xxx:xxx:war:0.1-20130528.050526-1 from/to snapshots (http://myserver.com/artifactory/libs-snapshots-local)
The 'repositories' tag is used for resolution, not for deployment. I'd speculate that the id of the repository under 'distributionManagment' tag is 'myserver.com', that's why it matches the server declaration in settings.xml
You settings.xml is missing the <servers> </servers> tags around your two <server> nodes. - https://maven.apache.org/settings.html#Servers
Also, I would avoid using generic id's like 'snapshots' and 'central'. Understandable if they are there for the purpose of SO.
The last update to this question didn't include the specific error code, but in the original error it was a 401 (Unauthorized) which leads me to believe that it's not able to find your servers authentication information due to invalid settings.xml

Resources