0

I've been trying for almost a day now to deploy jar files from Jersey to our local Artifactory using Maven. I have made a few small changes to branch 2.6.x of Jersey and have built and packaged the jars. Here is the excerpt of parent pom from Jersey:

<groupId>org.glassfish.jersey</groupId>
<artifactId>project</artifactId>
<packaging>pom</packaging>
<version>2.6.rn-SNAPSHOT</version>
<name>jersey</name>
<description>
    Jersey is the open source (under dual CDDL+GPL license) JAX-RS 2.0 (JSR 339)
    production quality Reference Implementation for building RESTful Web services.
</description>

<distributionManagement>
    <repository>
        <id>central</id>
        <name>central-repo</name>
        <url>http://localhost/artifactory/libs-releases-local</url>
    </repository>
    <snapshotRepository>
        <id>snapshots</id>
        <name>central-repo-snapshots</name>
        <url>http://localhost/artifactory/libs-snapshots-local</url>
    </snapshotRepository>
</distributionManagement>

I have my settings.xml generated by artifactory and placed in ~/.m2/settings.xml

But when I try to deploy using mvn deploy, I get the following:

Uploading: (https: //maven.java.net/content/repositories/snapshots/):
Failed to transfer file: https://maven.java.net/content/repositories/snapshots/org/glassfish/jersey/project/2.6.rn-SNAPSHOT/project-2.6.rn-20150218.212627-1.pom.
Return code is: 401, ReasonPhrase: Unauthorized.

My complete settings.xml looks like this:

<?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>admin</password>
      <id>central</id>
    </server>
    <server>
      <username>admin</username>
      <password>admin</password>
      <id>snapshots</id>
    </server>
  </servers>
  <profiles>
    <profile>
      <repositories>
        <repository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>libs-releases</name>
          <url>http://localhost/artifactory/libs-releases</url>
        </repository>
        <repository>
          <snapshots />
          <id>snapshots</id>
          <name>libs-snapshots</name>
          <url>http://localhost/artifactory/libs-snapshots</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>plugins-releases</name>
          <url>http://localhost/artifactory/plugins-releases</url>
        </pluginRepository>
        <pluginRepository>
          <snapshots />
          <id>snapshots</id>
          <name>plugins-snapshots</name>
          <url>http://localhost/artifactory/plugins-snapshots</url>
        </pluginRepository>
      </pluginRepositories>
      <id>artifactory</id>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>artifactory</activeProfile>
  </activeProfiles>
</settings>
Dror Bereznitsky
  • 20,048
  • 3
  • 48
  • 57
Sam
  • 376
  • 3
  • 13
  • When you're trying to upload your artifact you usually need a user and password (who's privileged to upload artifacts). [This](http://stackoverflow.com/questions/16773427/maven-repository-authentication) could help you. – Jan Feb 18 '15 at 22:07
  • Thanks for your response. The problem is that it shouldn't be trying to upload to that repository in the first place (it's trying to upload to maven.java.net) instead of uploading to my local artifactory) – Sam Feb 18 '15 at 23:15
  • Oh sry. Didn't read that. I setup a new project and added your provided config to my pom. Without any changes within the settings.xml maven tried to contact the server within the distribution management. That means your failure may depend on something else. Do you use profiles? Or do you may have a pom structure with a parent pom? – Jan Feb 18 '15 at 23:40
  • In the settings generated by artifactory, try switching repositories id from `central` to `something-central` and `snapshots` to `something-snapshots`. – Bruno Ribeiro Feb 19 '15 at 15:10
  • @Jan Yeah, it's the whole jersey project that I liked on top of the page, so there is a parent pom and millions of small poms. I have added the distributionManagement tag to my parent pom. Should I add that only to those pom's that I want to be deployed? – Sam Feb 19 '15 at 17:05
  • Yeah I think you should add that just to the poms you want to deploy that way or create a parent pom for those project which should be deployed the same way. Just don't know atm how the inheritance works there. Maven just tried to connect to configured repo if I was calling maven on the pom which contained the distribution management. But [this](http://stackoverflow.com/questions/3298135/how-to-specify-mavens-distributionmanagement-organisation-wide) seems to be the same discussion – Jan Feb 20 '15 at 09:47
  • Just adding here that solution for me seemed to be with profiles. Also Jersey's parent pom itself had a parent pom pointing to net.java (jvnet-parent). I removed that and used the right profile and managed to get it to deploy. – Sam Feb 23 '15 at 05:19

1 Answers1

0

You must add the distributionManagement tag in your pom.xml, where the url will be your Artifactory's url and add the credentials in settings.xml

You can read more about this here.

Eddú Meléndez
  • 6,107
  • 1
  • 26
  • 35