Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

upload aem maven artifacts to Sonatype Nexus Repository error

Avatar

Level 4

hi all,

 

i am trying to push my maven build artifacts to sonatype nexus repo.

i am following the blog Maven Deploy to Sonatype Nexus Repo

I am getting the below error -

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:3.1.1:deploy (default-deploy) on project xyz: Failed to deploy artifacts: Could not transfer
artifact com.xyz.aem:aem:pom:1.0.0-20240122.075117-1 from/to nexus-snapshots (http://yy.xx.zz.aa:8080/nexus/content/repositories/snapshots status code: 405, reason phrase: Method Not Allowed (405) -> [Help 1]

 

what will be the best way to publish artifact to the nexus sonatype?

also, how to resolve this issue?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

First of all, let me clarify that this is not an AEM-related task but a Maven process. Therefore, you can check in more forums about this process. The error you are encountering is due to the incorrect Nexus repository URL you are trying to access. Please refer to this thread for more details: https://stackoverflow.com/questions/63414621/405-method-not-allowed-when-deploying-artifact-to-nexus.

Typically, the most effective way to push an artifact to Nexus is by using the maven-deploy-plugin, which is generally suitable for AEM projects. If you need more advanced capabilities while interacting with Nexus, there are other Maven plugins that can be employed.

For step-by-step guidance on achieving this, please refer to the following articles:

  1. https://rodolfombc.medium.com/deploying-java-artifacts-on-a-nexus-repository-with-maven-939a80406acf
  2. https://www.baeldung.com/maven-deploy-nexus

 

I hope this helps



Esteban Bustamante

View solution in original post

7 Replies

Avatar

Level 8

Hi @aem_noob 

Make sure you have the necessary credentials and access rights to publish artifacts to the Nexus repository.

Update your Maven settings.xml file with the Nexus repository details. The settings.xml file is usually located in the .m2 directory in your user home directory. Add the following configuration:

<servers>
<server>
<id>nexus-snapshots</id>
<username>your-username</username>
<password>your-password</password>
</server>
<server>
<id>nexus-releases</id>
<username>your-username</username>
<password>your-password</password>
</server>
</servers>
xml
Replace your-username and your-password with your Nexus credentials.

In your Maven pom.xml file, make sure you have the correct distribution management configuration. Here's an example:
<distributionManagement>
<repository>
<id>nexus-snapshots</id>
<url>http://yy.xx.zz.aa:8080/nexus/content/repositories/snapshots</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<url>http://yy.xx.zz.aa:8080/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
xml
Replace http://yy.xx.zz.aa:8080/nexus/content/repositories/snapshots with the URL of your Nexus repository.

Run the Maven deploy command to publish your artifacts to Nexus:
mvn deploy
shell
Now, regarding the error you mentioned, the status code 405 indicates that the HTTP method used is not allowed. This could be due to incorrect configuration or access restrictions on the Nexus repository.
1.Check Nexus Repository Configuration
2.Update Maven Deployment Configuration
3.Maven Deployment Plugin Configuration
4.Nexus Credentials
5.Check Nexus Logs
6.Use Correct Maven Goals

Avatar

Level 4

acls and privileges are ok, the credentials are valid

nexus logs won't help as the artifact didn't get pushed to the server

maven goals are correct

for configuration its mostly ip address and url - i will check that again once -thanks

 

Avatar

Correct answer by
Community Advisor

Hi,

First of all, let me clarify that this is not an AEM-related task but a Maven process. Therefore, you can check in more forums about this process. The error you are encountering is due to the incorrect Nexus repository URL you are trying to access. Please refer to this thread for more details: https://stackoverflow.com/questions/63414621/405-method-not-allowed-when-deploying-artifact-to-nexus.

Typically, the most effective way to push an artifact to Nexus is by using the maven-deploy-plugin, which is generally suitable for AEM projects. If you need more advanced capabilities while interacting with Nexus, there are other Maven plugins that can be employed.

For step-by-step guidance on achieving this, please refer to the following articles:

  1. https://rodolfombc.medium.com/deploying-java-artifacts-on-a-nexus-repository-with-maven-939a80406acf
  2. https://www.baeldung.com/maven-deploy-nexus

 

I hope this helps



Esteban Bustamante

Avatar

Level 4

i m using non-browse based url only as the link suggested. i will try to switch back to maven deploy plugin as against the nexus-staging-maven-plugin once and update - thanks!

Avatar

Community Advisor

As mentioned by @EstebanBustamante, this is a URL related issue. Hit the URL in the browser and see if you are able to navigate to the repo.

You can also refer to the below URL for troubleshooting issues - 

https://stackoverflow.com/questions/18649486/error-when-deploying-an-artifact-in-nexus

Avatar

Level 4

browser giving 404 - look like issue with / ending

but why will the resp code show 405?