The timestamp in snapshot jar's maven-metadata.xml is more than a second than the actual jar's timestamp?
Asked Answered
E

6

11

I encountered a quirky problem:

I used "mvn deploy" (Maven 3.3.9, Jenkins 2.45, Nexus 2.12.0) to deploy a snapshot jar to my nexus in jenkins, result as below (suppose the jar name is userdao.jar):

Uploaded: myNexusIp/nexus/content/repositories/snapshots/xxx/1.0-SNAPSHOT/userdao-1.0-20170512.111840-6.jar 
Uploaded: myNexusIp/nexus/content/repositories/snapshots/xxx/1.0-SNAPSHOT/maven-metadata.xml

The build was successful and everything was OK.

But when I built another maven project that depended above userdao.jar, error occurred as below:

Could not find artifact userdao:jar:1.0-20170512.111840-6 in public (http://myNexusIp/nexus/content/groups/public/)

After positioning I found that the timestamp in maven-metadata.xml in the nexus was more than a second than the actual jar's timestamp!
As below:

  • in maven-metadata.xml: 1.0-20170512.111840-6
  • actual existing snapshot jar: userdao-1.0-20170512.111839-6.jar

Because userdao-1.0-20170512.111840-6.jar did not exist in Nexus, the right one should be userdao-1.0-20170512.111839-6.jar, so it errors.

Who can tell me why and how to resolve it?

Eyebolt answered 14/5, 2017 at 4:56 Comment(4)
Have you checked your log file that the userdao-.. is only uploaded once in your whole build...Tales
Hi khmarbaise,Thank you for your reminding, I found that userdao.jar's maven-metadata.xml was always updated 2 times in jenkins build log. And that if 2 updates were in a second there was no error, once 2 updates were in different seconds(e.g. one was 111839 and another was 111840), error occurred.Eyebolt
Hi khmarbaise, why was uploading file executed twice and how can i resolve it?Eyebolt
Hi how did you build the jar name can you please add your pom i am going through same problem that might help @EyeboltMundell
G
7

I actually found the opposite. After upgrading from Maven 3.3.9 to 3.5.0 I could reliably deploy artifacts where by the time stamps appearing in the metadata.xml files on Nexus were incorrect compared to the actual files that were deployed.

By downgrading (back to 3.3.9) everything worked correctly. The metadata.xml versions and timestamps matched always.

Perhaps it's something to do with the Maven 3.5.0 upgrade to remove Aether?

Galven answered 6/6, 2017 at 17:0 Comment(2)
I agree. +1. I also seen instances of incorrect timestamp with maven 3.5.0. I stick with 3.3.9 for now for any mvn deploy-file task.Waxen
Yes, there is an issue in Maven 3.5.0: issues.apache.org/jira/browse/MDEPLOY-221 which was fixed in 3.5.1Lightfingered
V
6

This has been confirmed a maven-3.5 issue https://issues.apache.org/jira/browse/MNG-6240 and a fixed applied. The release of maven-3.5.1 with the fix is voted here https://www.mail-archive.com/[email protected]/msg114783.html

Verbenia answered 29/9, 2017 at 15:2 Comment(1)
Maven 3.5.2 is now released , this issue should be fixed!Verbenia
W
1

The first thing to try is to rebuild your metadata on the repo where you uploaded your snapshot artifact.

See "Managing Scheduled Tasks"

Rebuild Maven Metadata Files

This task will rebuild the maven-metadata.xml files with the correct information and will also validate the checksums (.md5/.sha1) for all files in the specified Repository/Group.
Typically this task is run manually to repair a corrupted repository.

Waxen answered 14/5, 2017 at 6:9 Comment(4)
Hi VonC, I already created a task "Rebuild Maven Metadata Files" in my Nexus and run it according to your advice, I will trace it, thanks a lot.Eyebolt
Rebuild metadata is a repair operation, it isn't needed in normal cases. It's the responsibility of maven to download, update, and upload maven-metadata.xml files. As seen above, this issue was caused by a problem in the maven build (it was uploading twice).Rinaldo
@Rinaldo the second upload should have updated the maven-metadata.xml, no?Waxen
@Vonc "Rebuild Maven Metadata Files" I created yesterday already executed but the issue still exists, so I guess that the root reason is that the maven-metadata.xml was uploated twice and the twice are not in the same second. I wonder why upload twice?Eyebolt
E
1

I updated maven from 3.3.9 to 3.5.0, found that the maven-metadata.xml was uploaded once and the issue was resolved! So I guess this is a bug in maven 3.3.9, my current solution is updating maven to 3.5.0.

Eyebolt answered 16/5, 2017 at 10:16 Comment(2)
Interesting +1 I don't see that listed as a fixed issue in maven.apache.org/docs/3.5.0/release-notes.html thoughWaxen
I don't see either, but I am sure after testing repeatably : under the condition of without changing any other configuration, when using maven 3.3.9, the maven-metadata.xml is always uploaded TWICE, once switch to maven 3.5.0, it is uploaded only ONCE.Eyebolt
P
0

I have faced same issue when using Maven 3.3.9. Tested by upgrading to Maven 3.5.4 but the issue still exists. The problem of maven-metadata.xml getting uploaded twice was due to spotbug maven plugin v3.1.3. It got resolved in the latest spotbug maven plugin version- 3.1.12 on which I have tested.

Papaverine answered 9/7, 2019 at 12:6 Comment(0)
B
0

I was experiencing the same problem with maven 3.3.9. In my case, upgrading to maven 3.5.4 fixed the problem, no more "twice everything" in the default-deploy phase.

Buffon answered 20/8, 2019 at 7:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.