When maven says "resolution will not be reattempted until the update interval of MyRepo has elapsed", where is that interval specified?

MavenArtifactory

Maven Problem Overview


With maven, I occasionally hit an artifact that comes from some 3rd-party repo that I haven't built or included in my repository yet.

I'll get an error message from the maven client saying that an artifact can't be found:

> Failure to find org.jfrog.maven.annomojo:maven-plugin-anno:jar:1.4.0 > in http://myrepo:80/artifactory/repo was cached in the local > repository, resolution will not be reattempted until the update > interval of MyRepo has elapsed or updates are forced -> [Help 1]

Now, I understand what this means, and can simply re-run my command with -U, and things usually work fine from there on out.

However, I find this error message to be extremely unintuitive and am trying to spare my co-workers some headaches.

I am trying to figure out if there is some place that I can modify this update interval setting.

  1. Is the update interval that is mentioned in this error message a client-side or server-side setting?
  2. If client-side, how do I configure it?
  3. If server-side, does anyone know how/if Nexus/Artifactory expose these settings?

Maven Solutions


Solution 1 - Maven

I used to solve this issue by deleting the corresponding failed to download artifact directory in my local repo. Next time I run the maven command the artifact download is triggered again. Therefore I'd say it's a client side setting.

Nexus side (server repo side), this issue is solved configuring a scheduled task. Client side, this is done using -U, as you already pointed out.

Solution 2 - Maven

you can delete the corresponding failed artifact directory in you local repository. And also you can simply use the -U in the goal. It will do the work. This works with maven 3. So no need to downgrade to maven 2.

Solution 3 - Maven

What basically happens is,According to default updatePolicy of maven.Maven will fetch the jars from repo on daily basis.So if during 1st attempt your internet was not working then it would not try to fetch this jar again untill 24hours spent.

Resolution :

Either use

mvn -U clean install

where -U will force update the repo

or use

<profiles>
    <profile>
      ...
      <repositories>
        <repository>
          <id>myRepo</id>
          <name>My Repository</name>
          <releases>
            <enabled>false</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>warn</checksumPolicy>
          </releases>
         </repository>
      </repositories>
      ...
    </profile>
  </profiles>

in your settings.xml

Solution 4 - Maven

I had a related problem, but Raghuram's answer helped. (I don't have enough reputation yet to vote his answer up). I'm using Maven bundled with NetBeans, and was getting the same "...was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced -> [Help 1]" error.

To fix this I added <updatePolicy>always</updatePolicy> to my settings file (C:\Program Files\NetBeans 7.0\java\maven\conf\settings.xml)

<profile>
  <id>nexus</id>
  <!--Enable 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>true</enabled><updatePolicy>always</updatePolicy></snapshots>
    </repository>
  </repositories>
 <pluginRepositories>
    <pluginRepository>
      <id>central</id>
      <url>http://central</url>
      <releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
      <snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
    </pluginRepository>
  </pluginRepositories>
</profile>

Solution 5 - Maven

While you can resolve this with a clean install (overriding any cached dependencies) as @Sanjeev-Gulgani suggests with mvn -U clean install

You can also simply remove the cached dependency that is causing the problem with

mvn dependency:purge-local-repository -DmanualInclude="groupId:artifactId"

See mvn docs for more info.

Solution 6 - Maven

According to the settings reference:

> updatePolicy: This element specifies how often updates should attempt to occur. Maven will compare the local POM’s timestamp (stored > in a repository’s maven-metadata file) to the remote. The choices are: > always, daily (default), interval:X (where X is an integer in minutes) > or never.

Example:

<profiles>
    <profile>
      ...
      <repositories>
        <repository>
          <id>myRepo</id>
          <name>My Repository</name>
          <releases>
            <enabled>false</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>warn</checksumPolicy>
          </releases>
         </repository>
      </repositories>
      ...
    </profile>
  </profiles>
  ...
</settings>

Solution 7 - Maven

This works after you delete the related dependency from your local maven repository

/user/.m2/repository/path

Solution 8 - Maven

This error can sometimes be misleading. 2 things you might want to check:

  1. Is there an actual JAR for the dependency in the repo? Your error message contains a URL of where it is searching, so go there, and then browse to the folder that matches your dependency. Is there a jar? If not, you need to change your dependency. (for example, you could be pointing at a top level parent dependency, when you should be pointing at a sub project)

  2. If the jar exists on the remote repo, then just delete your local copy. It will be in your home directory (unless you configured differently) under .m2/repository (ls -a to show hidden if on Linux).

Solution 9 - Maven

If you are using Eclipse then go to Windows -> Preferences -> Maven and uncheck the "Do not automatically update dependencies from remote repositories" checkbox.

This works with Maven 3 as well.

Solution 10 - Maven

You need to delete all "_maven.repositories" files from your repository.

Solution 11 - Maven

I had a similar error with a different artifact.

><...> was cached in the local repository, resolution will not be reattempted >until the update interval of central has elapsed or updates are forced

None of the above described solutions worked for me. I finally resolved this in IntelliJ IDEA by File > Invalidate Caches / Restart ... > Invalidate and Restart.

Solution 12 - Maven

If you use Nexus as a proxy repo, it has "Not Found Cache TTL" setting with default value 1440 minutes (or 24 hours). Lowering this value may help (Repositories > Configuration > Expiration Settings).

See documentation for more info.

Solution 13 - Maven

For Intellij users the following worked for me:

Right click on your package

Maven > Reimport 

and

Maven > Generate Sources and Update Folders

Solution 14 - Maven

How I got this problem,

When I changed from Eclipse Juno to Luna, and checkout my maven projects from SVN repo, I got the same issues while building the applications.

What I tried? I tried clean Local repository and then updating all the versions again using -U option. But my problem continued.

Then I went to Window --> Preferences -> Maven --> User Settings --> and clicked on Reindex button under Local Repository and wait for the reindex to happen.

That's all, the issue is resolved.

Solution 15 - Maven

Maven has updatePolicy settings for specifying the frequency to check the updates in the repository or to keep the repository in sync with remote.

  • The default value for updatePolicy is daily.
  • Other values can be always / never/ XX (specifying interval in minutes).

Below code sample can be added to maven user settings file to configure updatePolicy.

<pluginRepositories>
	<pluginRepository>
		<id>Releases</id>
		<url>http://<host>:<port>/nexus/content/repositories/releases/</url>
		<releases>
			<enabled>true</enabled>
			<updatePolicy>daily</updatePolicy>
		</releases>
		<snapshots>
			<enabled>false</enabled>
		</snapshots>
	</pluginRepository>				
</pluginRepositories>

Solution 16 - Maven

To finally answer the title question: It is (a client side setting) in (project, profile or settings)

[plugin]?[r|R]epository/[releases|snapshots]/updatePolicy

... tag.

The (currently, maven: 3.6.0, but I suppose "far backwards" compatible) possible values are :

> /** * Never update locally cached data. / public static final String UPDATE_POLICY_NEVER = "never"; /* * Always update locally cached data. / public static final String UPDATE_POLICY_ALWAYS = "always"; /* * Update locally cached data once a day. / public static final String UPDATE_POLICY_DAILY = "daily"; /* * Update locally cached data every X minutes as given by "interval:X". */ public static final String UPDATE_POLICY_INTERVAL = "interval";

The current (maven 3.6.0) evaluation of this tag is implemented as follows:

> public boolean isUpdatedRequired( RepositorySystemSession session, long lastModified, String policy ) { boolean checkForUpdates; if ( policy == null ) { policy = ""; } if ( RepositoryPolicy.UPDATE_POLICY_ALWAYS.equals( policy ) ) { checkForUpdates = true; } else if ( RepositoryPolicy.UPDATE_POLICY_DAILY.equals( policy ) ) { Calendar cal = Calendar.getInstance(); cal.set( Calendar.HOUR_OF_DAY, 0 ); cal.set( Calendar.MINUTE, 0 ); cal.set( Calendar.SECOND, 0 ); cal.set( Calendar.MILLISECOND, 0 ); checkForUpdates = cal.getTimeInMillis() > lastModified; } else if ( policy.startsWith( RepositoryPolicy.UPDATE_POLICY_INTERVAL ) ) { int minutes = getMinutes( policy ); Calendar cal = Calendar.getInstance(); cal.add( Calendar.MINUTE, -minutes ); checkForUpdates = cal.getTimeInMillis() > lastModified; } else { // assume "never" checkForUpdates = false; if ( !RepositoryPolicy.UPDATE_POLICY_NEVER.equals( policy ) ) { LOGGER.warn( "Unknown repository update policy '{}', assuming '{}'", policy, RepositoryPolicy.UPDATE_POLICY_NEVER ); } } return checkForUpdates; }

..with:

> private int getMinutes( String policy ) { int minutes; try { String s = policy.substring( RepositoryPolicy.UPDATE_POLICY_INTERVAL.length() + 1 ); minutes = Integer.valueOf( s ); } catch ( RuntimeException e ) { minutes = 24 * 60; LOGGER.warn( "Non-parseable repository update policy '{}', assuming '{}:1440'", policy, RepositoryPolicy.UPDATE_POLICY_INTERVAL ); } return minutes; }

...where lastModified is the (local file) "modified timestamp" of an/each underlying artifact.


In particular for the interval:x setting:

  • the colon : is not that strict - any "non-empty" character could do it (=, , ...).
  • negative values x < 0 should yield to "never".
  • interval:0 I would assume a "minutely" (0-59 secs. or above...) interval.
  • number format exceptions result in 24 * 60 minutes (~"daily").

..see: DefaultUpdatePolicyAnalyzer, DefaultMetadataResolver#resolveMetadata() and RepositoryPolicy

Solution 17 - Maven

In my case the solution was stupid: I just had incorrect dependency versions.

Solution 18 - Maven

Somewhat relevent.. I was getting >"[ERROR] Failed to execute goal on project testproject: Could not resolve dependencies for project myjarname:jar:1.0-0: Failure to find myjarname-core:bundle:1.0-0 in http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]"

This error was caused by accidentally using Maven 3 instead of Maven 2. Just figured it might save someone some time, because my initial google search led me to this page.

Solution 19 - Maven

I had this problem and the comprehensive descriptions proposed in this helped me to fix it.

The second declared problem was my issue. I used a third-party repository which I had just added it do the repository part of the pom file in my project. I add the same repository information into pluginrepository to resolve this problem.

Solution 20 - Maven

I ran into the same problems with uploaded third party libraries on my private repository. Sometimes the described fixes worked for me, but sometimes they did not.

I think the root cause of the problem is a missing pom.xml file for the artifact. (The pom.xml for the third party artifact not your pom.xml in your project). I assume Maven expects for every artifact a pom.xml, so it can resolve the dependencies for all artifacts. Sometimes it works without a pom.xml, but sometimes it does not (I have not identified, when it does not).

I use Nexus3 as a private repository. When you upload an artifact, you can check an option to generate a pom.xml file for the artifact.

Solution 21 - Maven

Changing the localRepository path in my settings.xml solved the issue

Solution 22 - Maven

Make sure that the artifact you are looking for is exist , if its on your local project run : cd .. cd project name mvn clean install

Then you will have it locally.

for better practice do : mvn clean deploy so you can use it again without this problem

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questioncprice404View Question on Stackoverflow
Solution 1 - MavenChristian AchilliView Answer on Stackoverflow
Solution 2 - MavenkdsView Answer on Stackoverflow
Solution 3 - MavenSanjeev GuglaniView Answer on Stackoverflow
Solution 4 - MavenMrDrewsView Answer on Stackoverflow
Solution 5 - MavensfletcheView Answer on Stackoverflow
Solution 6 - MavenRaghuramView Answer on Stackoverflow
Solution 7 - MavenPravin BansalView Answer on Stackoverflow
Solution 8 - MavenMattCView Answer on Stackoverflow
Solution 9 - MavenashokaView Answer on Stackoverflow
Solution 10 - MavenRiadhView Answer on Stackoverflow
Solution 11 - MavenNoraTView Answer on Stackoverflow
Solution 12 - MavenchipiikView Answer on Stackoverflow
Solution 13 - MavenEmericView Answer on Stackoverflow
Solution 14 - MavenLyju I EdwinsonView Answer on Stackoverflow
Solution 15 - MavenVysakhan KasthuriView Answer on Stackoverflow
Solution 16 - Mavenxerx593View Answer on Stackoverflow
Solution 17 - MavenMaria Pomazkina-KarpikovaView Answer on Stackoverflow
Solution 18 - MavensdanzigView Answer on Stackoverflow
Solution 19 - MavenAmin Heydari AlashtiView Answer on Stackoverflow
Solution 20 - MavenhamiView Answer on Stackoverflow
Solution 21 - MavenMert AksoyView Answer on Stackoverflow
Solution 22 - MavenTal HakmonView Answer on Stackoverflow