Nexus accepts upload but says it failed - java

When I execute mvn release:perform on a parent POM, the server is responding with this error about one of the child projects (filenames redacted):
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file
(default-cli) on project: Failed to deploy artifacts: Could not
transfer artifact from/to repository: Failed to transfer file.
Return code is: 400, ReasonPhrase: Bad Request.
However, all the files for this child project are successfully uploaded! I see a new directory (named after the release version number) and it contains all the .jar, .pom, .md5, and .sha1 files one would expect.
I don't have access to the Nexus server, but I'm wondering what might cause this and how to fix it. Is it possible that Maven is trying to upload this particular child project twice? If so, why would Maven be doing this and how can I stop it?
UPDATE: If you're having the same problem, check out the answer with the most upvotes in this post. I ran mvn help:effective-pom and found that the project in question actually had two executions of the deploy phase. Removing one of those executions solved my problem.

I encountered the same issue, releasing a maven multi-module project. An error occured the first time but the deploy goal had already contact nexus and then create the appropriate path. Assuming that a "release" repo is a write-once one, the second time I trggered it, nexus refuse to overwrite the path.
So, in such a case, you might ask your admin to delete the repo ... or create a new release.
PS : better late than never ;)

Related

Issue while adding a new maven module to a maven project

I've added a new maven module B to an existing maven project A.
Apart from module B, A contains additional 2 modules C & D.
I've properly defined the module B inside parent pom.xml.
I've also added the parent tag inside module B pom.xml. The versions of all the modules as the parent are 0.0.X-SNAPSHOT.
Now when I do a mvn clean install deploy, it always throws exception:
Failed to create archive: Could not find artifact B:jar:0.0.X-SNAPSHOT in central (https://nexus.xyz.com/content/groups/public) ,which kind-off makes sense.
Hence,as a last resort, I tried to manually push the file into the nexus repo using using mvn deploy:deploy-file command.
Now, if I again do mvn clean install deploy,it works smoothly.
But the problem re-appears when I try to release the project.
This time, it complains:
Failed to create archive: Could not find artifact B:jar:0.0.X in central (https://nexus.xyz.com/content/groups/public)
I tried with mvn clean install -U as well but in vain.
The problem doesn't appear for any other modules.
Kindly advise.Thanks.
Okay...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. :)

Error building Alfresco CE 5.0a in eclipse

I am trying to build Alfresco CE 5.0a in Eclipse.I followed steps according to this link. The checkout was successful.But while building the sourcecode using maven(using clean install) I am getting the following error.
[ERROR] Failed to execute goal on project alfresco-core: Could not resolve dependencies for project org.alfresco:alfresco-core:jar:5.0.a: The following artifacts could not be resolved: org.mybatis:mybatis:jar:3.0.4-alfresco-patched, org.springframework.extensions.surf:spring-surf-core-configservice:jar:1.2.1-M16, org.springframework.extensions.surf:spring-surf-core:jar:1.2.1-M16, org.springframework:spring-web:jar:3.0.5.RELEASE, javax.servlet:servlet-api:jar:2.4: Could not transfer artifact org.mybatis:mybatis:jar:3.0.4-alfresco-patched from/to alfresco-public (https ://artifacts.alfresco.com/nexus/content/groups/public): No response received after 60000 -> [Help 1]
I guess this is because of this jar file under the Alfresco Core 5.0.a
Downloaded: http ://repo.maven.apache.org/maven2/org/mockito/mockito-all/1.9.5/mockito-all-1.9.5.jar
I couldn't find that jar file in the specified URL.
So how can I solve this.Can I change the dependancy in pom.xml?
Help Needed.Thanks in Advance.
First Question Will be ,Why you would like to compile alfresco source code?Are you aware that We can do many customization without customizing alfresco source code.
Above was only for your information.
First try to compile it without using eclipse.Due to that you are facing error.
If still problem persist, remove dependencies from your .m2 directory of your maven and make maven download this dependencies again.If you face similar error again for different jar than remove it from .m2 and again fire clean install command.
This will definitely solve your problem.
It may be that , above mentioned error is listing your all corrupted jar files so remove first and try it again

Could not resolve dependencies while building in Maven

Hi I am trying to build a maven project.
After building initial projects successfully, its failing. The error shows that it failed to collect dependency from a particular location in the local repository.
When I went to that location the jar files are missing in it. So I guess it is supposed to download from the remote repository.
I am wondering whether it fails to download or I am getting anything wrong? Also a few posts suggest to delete the .m2 folder. Will that cause any problems or am I suppose to delete the few folders in it?
Thanks
Try to force update dependencies with the switch -U. At least you can be sure that it is not because of your local error in .m2.

Maven not able to download dependency

I have started working on a new project using Maven, and I'm unable to have it work properly on eclipse. I have multiples of this error :
ArtifactTransferException: Failure to transfer com.caucho:hessian:jar:3.1.5 from <repository> was cached in the local repository, resolution will not be reattempted until the update interval of Archiva SIVPN Internal has elapsed or updates are forced. Original error: Could not transfer artifact com.caucho:hessian:jar:3.1.5 from/to Archiva SIVPN Internal (<repository>): No response received after 60000 pom.xml /<file> line 2 Maven Dependency Problem
Description Resource Path Location Type
Missing artifact com.caucho:hessian:jar:3.1.5 pom.xml / line 2 Maven Dependency Problem
After doing some research, I found that it was probably either the pom.xml that's wrong, or that I have proxy problems.
I checked that the resource was available on our repository, and that the pom snippet is the same as declared in my code :
<dependency>
<groupId>com.caucho</groupId>
<artifactId>hessian</artifactId>
<version>3.1.5</version>
</dependency>
My proxy works just fine for the trunk of the project, and there is no other proxy I'm aware of.
I thought it was maybe a one-time connection problem, but making a new maven build with -U didn't resolve the problem.
I also found https://stackoverflow.com/questions/6111408/maven2-missing-artifact-but-jars-are-in-place
with several I-don't-know-what-else-to-do solutions, but it didn't work for me...
Since the lead developer is on vacation and I have little experience on mvn, could someone tell me other potential problems that could be responsible for this ?
Thanks in advance for answers :)
Open a command prompt, go to your project directory and run: mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true
The eclipse:eclipse portion will regenerate your project files etc, the last 2 properties are more for convenience but I like downloading the sources and javadoc.
After a failed attempt, maven will leave a small file in your local .m2 repository that will prevent any attempt to re-download the file unless the update interval has elapsed or you force the updates using the maven -U switch described in other answers.
Just delete the folder for that artifact in your local m2 repository and update you project; a new download attempt will trigger.
rm -rf ~/.m2/repository/com/caucho/hessian/3.1.5

Strategy for maven deploy via a Jenkins job

I have a Jenkins job that use maven build goals 'clean package deploy' for the master git branch. However, due to the nexus repo not allowing redeploys, if the Jenkins job runs a second time without the version changing, it will fail with the expected 400 Bad Request error:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal
org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy)
on project common-library:
Failed to deploy artifacts: Could not transfer artifact
net.bacon.common:common-library:pom:1.2.13 from/to bacon-releases
(https://maven.bacon.com/nexus/content/repositories/releases):
Failed to transfer file:
https://maven.bacon.com/nexus/content/repositories/releases/net/bacon/common/common-library/1.2.13/common-library-1.2.13.pom.
Return code is: 400, ReasonPhrase:Bad Request.
Can anyone suggest a different strategy, whereby the deploy goal can run without making the Jenkins job fail?
what we do is automatic snapshot builds. then, the version is automatically incremented.
for release build, we use the maven release plugin and enter the version manually. you can, however, let the release plugin do the work. it will remove the "-SNAPSHOT" build, deploy, and then, for the next release version increment the last digit and append the "-SNAPSHOT" again.
for the distribution management, you can have two repos, one for snapshots and one for releases, with different redeploy settings.
We apply a "double action" solution:
Increment version
Run mvn install
Run tests
If all passed, we run mvn deploy
This way, we do not try to deploy before we know all passed and we have a unique version deployed every time.
I hope this helps.
You should make sure, that each commit on master carries its own version number on the pom file. So you won't have redeploys.
There is a good reason for rejecting the "redeploys": The content of a released version should never change.
If you can't avoid commits for the same version number on master, consider changing the chained jenkins job to "clean install" (stores the artifacts only on the local repository) and create a new job with "clean deploy" that is only started manually.
This is an issue for our group as well.
We want maven to attempt a PASSIVE deploy, so if the deploy exists at nexus then it will acceptably move on with SUCCESS ALREADY DEPLOYED, and if the deploy does not exist at nexus, it will upload and deploy with SUCCESS.
We want jenkins to deploy after it builds and passes coverage check, but how to make it so that only the un-deployed will get deployed, and the already-deployed are ignored.
Our solution was a custom script.
You can use the release candidate concept. When you start the release you add -RC1 to the version (1.1.0-RC1 for example).
With the next redeploy you are increment the RC number. When the release is finished and you want to generate a new TAG, you only delete the RC for the version. before the TAG creation

Categories

Resources