mavenjunitmaven-3artifactoryartifact

Could not find artifact junit:junit:jar:4.12 in central


I use Artifactory.

Intranet                           |      Internet
---------------------------------------------------------------------
client <------> Artifactory <------|----> Remote repository: jcenter

When I run (after removing the .m2 content related to JUnit)

mvn clean package -U

on the client, I get the following error:

[ERROR] Failed to execute goal on project MyProject: Could not resolve dependencies for project com.company:MyProject:war:0.0.1-SNAPSHOT: Could not find artifact junit:junit:jar:4.12 in central (http://my-own-server:8081/artifactory/libs-release) -> [Help 1]

part of the following output:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MyProject Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://my-own-server:8081/artifactory/libs-release/junit/junit/4.12/junit-4.12.pom
Downloaded: http://my-own-server:8081/artifactory/libs-release/junit/junit/4.12/junit-4.12.pom (24 KB at 164.0 KB/sec)
Downloading: http://my-own-server:8081/artifactory/libs-release/com/oracle/ojdbc7/12.1.0.1/ojdbc7-12.1.0.1.pom
[WARNING] The POM for com.oracle:ojdbc7:jar:12.1.0.1 is missing, no dependency information available
Downloading: http://my-own-server:8081/artifactory/libs-release/junit/junit/4.12/junit-4.12.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.484s
[INFO] Finished at: Thu Feb 25 17:19:01 EET 2016
[INFO] Final Memory: 8M/155M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project MyProject: Could not resolve dependencies for project com.company:MyProject:war:0.0.1-SNAPSHOT: Could not find artifact junit:junit:jar:4.12 in central (http://my-own-server:8081/artifactory/libs-release) -> [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 fix this problem?


Details:

  1. The connection between Artifactory and the remote repository works.

    • tested from Artifactory, using the Test button
    • the other .jar files are brought into .m2/repository (E.g.: log4j-1.2.17.jar)
  2. The junit/junit/4.12 folder is created under .m2/repository, but it contains only the following files:

    • _maven.repositories
    • junit-4.12.jar.lastUpdated
    • junit-4.12.pom
    • junit-4.12.pom.sha1
  3. The jcenter remote repository contains JUnit 4.12: http://jcenter.bintray.com/junit/junit/4.12/

  4. Running

    mvn clean package -U -X
    

    will show the following output

    ...
    Downloading: http://my-own-server:8081/artifactory/libs-release/junit/junit/4.12/junit-4.12.jar
    [DEBUG] Writing resolution tracking file C:\Users\first.last\.m2\repository\junit\junit\4.12\junit-4.12.jar.lastUpdated
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 1.903s
    [INFO] Finished at: Thu Feb 25 17:25:51 EET 2016
    [INFO] Final Memory: 9M/155M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal on project MyProject: Could not resolve dependencies for project com.company:MyProject:war:0.0.1-SNAPSHOT: Could not find artifact junit:junit:jar:4.12 in central (http://my-own-server:8081/artifactory/libs-release) -> [Help 1]
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project MyProject: Could not resolve dependencies for project com.company:MyProject:war:0.0.1-SNAPSHOT: Could not find artifact junit:junit:jar:4.12 in central (http://my-own-server:8081/artifactory/libs-release)
            at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:210)
            at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies(LifecycleDependencyResolver.java:117)
            at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved(MojoExecutor.java:258)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:201)
            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:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:497)
            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.project.DependencyResolutionException: Could not resolve dependencies for project com.company:MyProject:war:0.0.1-SNAPSHOT: Could not find artifact junit:junit:jar:4.12 in central (http://my-own-server:8081/artifactory/libs-release)
            at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:189)
            at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:185)
            ... 22 more
    Caused by: org.sonatype.aether.resolution.DependencyResolutionException: Could not find artifact junit:junit:jar:4.12 in central (http://my-own-server:8081/artifactory/libs-release)
            at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:375)
            at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:183)
            ... 23 more
    Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Could not find artifact junit:junit:jar:4.12 in central (http://my-own-server:8081/artifactory/libs-release)
            at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:538)
            at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:216)
            at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:358)
            ... 24 more
    Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Could not find artifact junit:junit:jar:4.12 in central (http://my-own-server:8081/artifactory/libs-release)
            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$GetTask.run(WagonRepositoryConnector.java:669)
            at org.sonatype.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:60)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
            at java.lang.Thread.run(Thread.java:745)
    [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/DependencyResolutionException
    
  5. If I upload manually the junit-4.12.jar file in http://my-own-server:8081/artifactory/webapp/#/artifacts/browse/tree/General/libs-release-local , it works, but I'd like to keep that folder only for the files that are not in the official remote repositories (like ojdbc7.jar).

  6. The following URL http://my-own-server:8081/artifactory/libs-release/junit/junit/4.12/junit-4.12.jar?trace contains:

    Request ID: ...
    Repo Path ID: libs-release:junit/junit/4.12/junit-4.12.jar
    Method Name: GET
    User: admin
    Time: 2016-02-25T18:02:35.664+02:00
    Thread: http-nio-8081-exec-346
    Steps: 
    2016-02-25T18:02:35.664+02:00 Received request
    2016-02-25T18:02:35.664+02:00 Request source = <ip>, Last modified = 01-01-70 01:59:59 +02:00, If modified since = -1, Thread name = http-nio-8081-exec-346
    2016-02-25T18:02:35.664+02:00 Executing any BeforeDownloadRequest user plugins that may exist
    2016-02-25T18:02:35.664+02:00 Retrieving info
    2016-02-25T18:02:35.664+02:00 Consulting the virtual repo download strategy
    2016-02-25T18:02:35.664+02:00 Trying to retrieve resource info from the local storage
    2016-02-25T18:02:35.664+02:00 Unable to find resource in libs-release:junit/junit/4.12/junit-4.12.jar
    2016-02-25T18:02:35.664+02:00 Searching for info in aggregated repositories
    2016-02-25T18:02:35.664+02:00 Preparing list of aggregated repositories to search in
    2016-02-25T18:02:35.664+02:00 Appending the virtual repository 'libs-release'
    2016-02-25T18:02:35.664+02:00 Appending the virtual repository 'libs-release'
    2016-02-25T18:02:35.664+02:00 Appending the virtual repository 'libs-release'
    2016-02-25T18:02:35.664+02:00 Appending collective local repositories
    2016-02-25T18:02:35.664+02:00 Appending collective local cache repositories
    2016-02-25T18:02:35.664+02:00 Appending collective remote repositories
    2016-02-25T18:02:35.664+02:00 Intercepting info request with 'MavenMetadataInterceptor'
    2016-02-25T18:02:35.664+02:00 Intercepting info request with 'PomInterceptor'
    2016-02-25T18:02:35.664+02:00 Processing request as a release resource
    2016-02-25T18:02:35.664+02:00 Searching for the resource within libs-release-local
    2016-02-25T18:02:35.664+02:00 Unable to find resource in libs-release-local:junit/junit/4.12/junit-4.12.jar
    2016-02-25T18:02:35.664+02:00 Searching for the resource within ext-release-local
    2016-02-25T18:02:35.664+02:00 Unable to find resource in ext-release-local:junit/junit/4.12/junit-4.12.jar
    2016-02-25T18:02:35.664+02:00 Searching for the resource within jcenter-cache
    2016-02-25T18:02:35.664+02:00 Unable to find resource in jcenter-cache:junit/junit/4.12/junit-4.12.jar
    2016-02-25T18:02:35.664+02:00 Searching for the resource within jcenter
    2016-02-25T18:02:35.664+02:00 Returning an unfound resource
    2016-02-25T18:02:35.664+02:00 Requested resource is found = false
    2016-02-25T18:02:35.664+02:00 Request is HEAD = false
    2016-02-25T18:02:35.664+02:00 Request is for a checksum = false
    2016-02-25T18:02:35.664+02:00 Target repository is not remote or doesn't store locally = true
    2016-02-25T18:02:35.664+02:00 Requested resource was not modified = false
    2016-02-25T18:02:35.664+02:00 Responding with unfound resource
    2016-02-25T18:02:35.664+02:00 Setting default response status to '404' reason to 'Resource not found'
    2016-02-25T18:02:35.664+02:00 Response is an instance of UnfoundRepoResourceReason
    2016-02-25T18:02:35.664+02:00 Configured to hide un-authorized resources = false
    2016-02-25T18:02:35.664+02:00 Original response status is auth related = false
    2016-02-25T18:02:35.664+02:00 Using original response status of '404' and message 'Could not find resource'
    2016-02-25T18:02:35.664+02:00 Sending error with status 404 and message 'Could not find resource'
    2016-02-25T18:02:35.664+02:00 Executing any AfterDownloadErrorAction user plugins that may exist
    2016-02-25T18:02:35.664+02:00 Response code wasn't modified by the user plugins
    2016-02-25T18:02:35.664+02:00 Sending response with the status '404' and the message 'Could not find resource'
    
  7. My pom.xml contains:

    <dependencies>
        <!-- JUnit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        ...
    </dependencies>
    
  8. Software versions:

    • Artifactory Version 4.5.1
    • Apache Maven 3.0.5

Solution

  • Looks like Artifactory have a missed retrieval cached in the jcenter-cache. If Artifactory failed to get junit from JCenter for some reason (for example a timeout) it will cache this failure for the period configured in the "Missed Retrieval Cache Period" property of the remote repository.
    You can clear this and force Artifactory to try and retrieve the artifact again by zapping the cache.

    Applied for this situation:

    1. Go to Artifacts > Artifact Repository Browser > jcenter-cache > junit/junit > 4.12

      or just click on

      http://my-own-server:8081/artifactory/webapp/#/artifacts/browse/tree/General/jcenter-cache/junit/junit/4.12

    2. Right click on 4.12 > Zap Cache:

      right click and Zap Cache