Maven Errors - Few common Maven error and troubleshooting part 1


In this post i am going to talk about maven build troubleshooting, Here is the list few maven error and its troubleshooting.

Tag Already exist

If you see following type of error in your release build after the perform step

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.3.2:prepare (default-cli) on project : Unable to tag SCM
[ERROR] Provider message:
[ERROR] The git-tag command failed.
[ERROR] Command output:

[ERROR] fatal: tag '<some tag>' already exists



Usually this means that tag already exist for same release and same tag can not be created. There could be several reasons for same.
  • manual tag was created.
  • Last release build failed after tag creation.
  • You are trying to release same version again.
  • Solution

    • You may delete the tag and rerun the build if tag was created my mistake.
    • Increase the version of your release and run the build.




Non Release dependency

If you see following type of error in your release build.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.3.2:prepare (default-cli) on project: Can't release project due to non released dependencies :


This means, Project has SNAOSHOP dependency in the pom, You can not release your project if it has snapshot artifact dependency of other project. Your Project should always point to release artifact as dependency.

Solution


  • Either release the other project first and use its latest released artifact in your dependency
OR
  • Use the already releases version of the artifact in your project.




Artifact already exist in maven repo-

Return code is: 400, ReasonPhrase:Bad Request


If you see following type of error in your release build

[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project : Failed to deploy artifacts: Could not transfer artifact  from/to release (http://maven.com/content/repositories/releases/): Failed to transfer file: . Return code is: 400, ReasonPhrase:Bad Request. -> [Help 1]

This means jar (which version) is already present in the maven repo and you are trying to release or upload same released/uploaded version again. There could be several reasons for same.
  • You are trying to perform same release again.
  • By mistake it was uploaded (somehow).
  • Previous release was bad and you want to stick to same version due to some external dependency.

Solution

According to the reasons you need to work on solution
  • You are trying to perform same release again.
    • Increase the version number and go ahead with new release.
  • By mistake it was uploaded (somehow).
    • Either you can increase the version and go ahead with new release or seek help from us to delete the old one.
  • Previous release was bad and you want to stick to same version due to some external dependency.
    • Delete the old one from maven repo.



Do not have snapshot in your pom

 If you see following type of error in your release build

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.3.2:prepare (default-cli) on project : You don't have a SNAPSHOT project in the reactor projects list. -> [Help 1]

This means your pom does not contain the "-SNAPSHOT" in the version field, this is must to have because release plugin will take care of removing snapshot and increasing version, tagging etc. 

Solution

Add "-SNAPSHOT" in your pom in version tag.



Return code is: 401, ReasonPhrase:Unauthorized

 If you see following type of error in your build

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project : Failed to deploy artifacts: Could not transfer artifact from/to release (http://maven.com/content/repositories/releases/): Failed to transfer file: http://maven.com/content/repositories/releases/com/something.jar. Return code is: 401, ReasonPhrase:Unauthorized. -> [Help 1]

This error says that you are trying to deploy/upload version of artifact and you do not have upload access to maven repo.

Solution

On the basis of issue here are the solutions.

Either, you do not have access to upload artifact to the give maven repo.
or
You can only deploy/upload the snapshot version of the artifact to maven repo.
Release version can only be uploaded Only once. You are trying to deploy the same version again.
You may have to remove the older version of same artifact to redeploy it again with same version.





Cached in the local repository

 if you see following type of error in your release build

[ERROR] Failed to execute goal on project : Could not resolve dependencies for project com.something:jar:0.0.2-SNAPSHOT: Failure to find com.something:jar:0.0.9-SNAPSHOT in http://artifactory.com:8080/artifactory/reliease 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 means your project is trying to download a jar which does not exist OR it is cached 
locally with the info but does not have right artifacts.

Solution
  1. Clean in the local .m2 for given jar, In above example go to ~/.m2/repository/com/something and delete the directory 0.0.9* and run the build again.
OR
  1. Please check if this artifacts exist in maven repo or not. Most probably you may have to check the existing version and point your dependency to that.

Comments

Popular posts from this blog

Colour formatting - Jenkins Console

Manage Docker images on local disk

How to migrate Parent pom from maven to gradle