44

I want to deploy a library to my companies remote repository.

It's the first time I want to deploy the library project to the remote repository.

I get the following error message:

org.sonatype.aether.transfer.ArtifactNotFoundException: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com/)

Maybe I understand something complete wrong, but the error message says, that in the remote repository doesn't exist the artifact that I try to deploy for the first time. So of course there is not such artifact. Why does maven tries to fetch the artifact when I try to upload the artifact?

My pom file:

<?xml version="1.0" encoding="UTF-8"?>
<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.0http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>com.http</groupId>
<artifactId>httpkit</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<name>httpkit</name>

<properties>
    <platform.version> 4.1.1.4</platform.version>
</properties>

<dependencies>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <version>${platform.version}</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

<!-- Deploy to internal maven repository -->
<distributionManagement>
    <repository>
      <id>internal.repo</id>
      <name>Internal Repository</name>
      <url>http://jenkins.internal.com/</url>
    </repository>
</distributionManagement>

<build>
    <plugins>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <version>3.5.3</version>
            <configuration>
                <androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
                <assetsDirectory>${project.basedir}/assets</assetsDirectory>
                <resourceDirectory>${project.basedir}/res</resourceDirectory>
                <nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
                <sdk>
                    <platform>16</platform>
                </sdk>
               <undeployBeforeDeploy>true</undeployBeforeDeploy>
            </configuration>
            <extensions>true</extensions>
        </plugin>

        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
            </configuration>
        </plugin>

    </plugins>
</build>
</project>

I call

mvn deploy

from command line

Any suggestion how to fix that problem?

EDIT: The failure log (running mvn deploy -X)

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project httpkit: Failed to deploy artifacts: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project httpkit: Failed to deploy artifacts: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to deploy artifacts: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com)
    at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:193)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
Caused by: org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com)
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:141)
    at org.apache.maven.plugin.deploy.AbstractDeployMojo.deploy(AbstractDeployMojo.java:167)
    at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:157)
    ... 21 more
Caused by: org.sonatype.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com)
    at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:280)
    at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:211)
    at org.sonatype.aether.impl.internal.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:443)
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:137)
    ... 23 more
Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com/)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:947)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:941)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:837)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector.put(WagonRepositoryConnector.java:467)
    at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:274)
    ... 26 more
[ERROR] 
[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/MojoExecutionException
ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
sockeqwe
  • 15,574
  • 24
  • 88
  • 144
  • What goal are you trying to run from the build that is failing? Can you please post the last few lines of the build log exactly as they appear? – Peter Mularien Apr 19 '13 at 17:26
  • Hi, the goal is org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy). I have added the error stack trace. – sockeqwe Apr 20 '13 at 19:39
  • 1
    Post your entire `pom.xml` and `settings.xml` files. Maven is not trying to download the actual jar of the project, but rather -- if there is a `.pom` file already deployed to the remote host. Whic version of Maven is this? Which artifact repository are you using (Nexus, Artifactory, Archiva)? Have you set up a user with proper permissions in it? – carlspring Apr 22 '13 at 09:57

11 Answers11

28

Have you tried to add the server in your settings.xml file? The default settings xml is located in your ~/.m2/ directory. Should contain something like that:

<servers>
        <server>
            <id>my-internal-nexus-repo</id>
            <username>yourUserName</username>
            <password>yourPassword</password>
        </server>
</servers>

Here is a link to the http://maven.apache.org/settings.html maven doc for adding servers.

One other thing which might be a shot in the dark. I've noticed you are trying to connect to what the url suggests might be a Jenkins instance. Jenkins is a Continious Integration server and seemed strange to me that you are finding your repositories there. I would expect a Nexus url or something.

Nikola Yovchev
  • 9,498
  • 4
  • 46
  • 72
  • Yeah, you are right. I had an error in reasoning. Jenkins has a maven repository plugin, but the idea is not to deploy to that plugin, like I would do with nexus (that was how I thought this plugin works), but to let jenkins build the project and add the artifacts to jenkins local maven repository. Then its possible for our developers to use jenkins local maven repository as a remote repository :) – sockeqwe Apr 22 '13 at 11:30
  • 1
    this is wrong. The id should be the same as the id in the pom so internal.repo and not the url – Manfred Moser Jan 09 '15 at 22:53
  • 2
    @ManfredMoser yes, you are right, shouldn't be the url of a repo, but the name of the thingy as you named it, e.g maven-central – Nikola Yovchev Jan 09 '15 at 22:58
  • I had added the settings.xml to my project folder. Now I know that settings.xml belongs to C:/Users/YourUsername/.m2 – Rameshwar Mar 21 '17 at 18:20
  • 1
    So I have this server block in my settings.xml, but still get this artifact not found error. Why is Maven looking for an artifact that obviously should not exist since I am just now uploading it for the first time?? This makes no sense at all. – Ian Tait Jun 19 '18 at 13:31
  • @IanTait would love to help you but you need to either open a new question, or post some more information, for example, what kind of maven command you are running, etc. – Nikola Yovchev Jun 19 '18 at 15:01
23

A possible cause is that you simply misspelt the repository name, or used the wrong repository name entirely

So using the OP's example:

Failed to deploy artifacts: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.
repo (http://jenkins.intrnal.com)

could actually mean

Failed to deploy artifacts: Could not find internal.repo (http://jenkins.intrnal.com)
Raedwald
  • 46,613
  • 43
  • 151
  • 237
randomsimon
  • 471
  • 4
  • 11
  • 4
    What a timely answer. I just hit this exact error today, and it was indeed a typo in the repo URL! – Alex Varju Jun 15 '15 at 21:43
  • I had the same error, in my case, in was that the host sits behind a proxy, and I needed to add the hosts to nonProxyHosts in settings.xml, maven does not use the OS proxy setttings, in particular no_proxy env variable on Linux – Tony BenBrahim Sep 16 '15 at 02:34
  • I did the same mistake. Thanks a lot. – Maurice Perry Nov 21 '18 at 16:03
  • I was trying to push into a self hosted Gitlab Maven registry, and I forgot that the url was https:///v4/projects//packages/maven instead of just https:///projects//packages/maven, and this answer actually made me realise the url looked fishy. – Clockwork May 16 '23 at 14:44
6

We have faced this issue. After couple of hours, we figured it is disk space issue in internal repository.

4

I ran into a similar problem and solved by

  1. Adding my nexus server as a nonProxyHost in settings.xml
  2. Setting the 3rd party's Repository Policy to Release rather than Snapshot.

See more details in my stackoverflow answer.

Note that I was doing a "mvn deploy:deploy-file" (which uploads a 3rd party artifact to the shared repository) whereas you are doing a "mvn deploy" (which uploads YOUR artifact from your built project to the shared repository), but the root cause maybe the same.

Community
  • 1
  • 1
Shaun Abram
  • 281
  • 1
  • 4
  • 10
2

Regarding the error:

Failed to deploy artifacts: Could not transfer artifact

Solution:

A very simple way to fix this is just by changing/updating the version in the pom.xml file. Suppose 01.16.03 is already used then try using 01.16.04 instead. It should work.

Elletlar
  • 3,136
  • 7
  • 32
  • 38
Kripa Mishra
  • 331
  • 3
  • 5
1

In my case my server url in snapshotRepository section of pom.xml was pointing to http, while my internal repository was hosted in https.

user320550
  • 1,093
  • 6
  • 20
  • 37
0

Okay...I encountered the same issue some days ago. And after fiddling around with all sort of permutations and combination, I finally arrived at the conclusion. Those who says that the reactor automatically sorts and resolves all dependencies on its own are incorrect. It seems that the link below describes it all. Kindly look at the last point under "Reactor Sorting" section:

https://maven.apache.org/guides/mini/guide-multiple-modules.html#Reactor_Sorting

It suggests that the order in which the modules are defined are taken into consideration when no other rules applies.

I hope that helps other. :)

Sandy
  • 459
  • 2
  • 6
  • 19
0

It is because your Maven not able to find settings file. If deleting .m2 not work, try below solution

Go to your JOB configuration

than to the Build section

Add build step :- Invoke top level maven target and fill Maven version and Goal

than click on Advance button and mention settings file path as mention in image enter image description here

Narender Gusain
  • 2,220
  • 17
  • 13
0

Today i encountered the same issue.My solution was to upgrade pom version.Sure,you can also modify the nexus settings so that the same version number can be uploaded repeatedly,but the second method I haven't practiced myself, you can try.

lufei
  • 1
0

In my case, Blob Store is almost running out of space. I have forgotten to set up clean-up policies. Once the disk space is cleared this issue is solved.

0

Maven knows the URL of the repository to deploy to from the repository (or snapshotRepository) sub elements of the distributionManagement element in the POM:

    <distributionManagement>
        <repository>
            <id>{some ID}</id>
            <name>{some helpful name}</name>
            <url>http://example.com:8081/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
           ...
        </snapshotRepository>
    </distributionManagement>

But Maven will also need to know the user-name and password to use. That can't be in the (public, published) POM, but is instead in a server element in your Maven settings file (~/.m2/settings.xml):

  <servers>
    <server>
      <id>{some ID}</id>
      <username>{username}</username>
      <password>{password}</password>
      <filePermissions>664</filePermissions>
      <directoryPermissions>775</directoryPermissions>
      <configuration></configuration>
    </server>
    ...
  </servers>

Because the settings file can contain credentials for multiple servers, it needs a means of associating your POM repository with the appropriate settings server. It uses the content of the id sub element to identify which server credentials to use with which repository.

Obviously, if you use the wrong id (completely wrong or having a typo) then Maven will not know which credentials to use. However, Maven does not output a warning or error message in this case. It tries (using no credentials?) to do the upload, which of course fails with 401 Unauthorized.

Therefore, if deployment fails with a mysterious 401 Unauthorized, one thing to check is that your repository and server id values are the same.

Raedwald
  • 46,613
  • 43
  • 151
  • 237