Search code examples
mavenmaven-3nexusnexus3

maven Failed to transfer jar file to nexus repository


I have a nexus installed on my server behind a Nginx reverse proxy. I created maven-snapshots and maven-releases repositories. Redeployment is allowed for both repositories. Version policies are Snapshot for maven-snapshots and Release for maven-releases I also created a Role with nx-repository-view-*-*-* privilege and a user nx-dev with that given role. In my maven settings:

<server>
  <id>nexus-snapshots</id>
  <username>nx-dev</username>
  <password>NX-DEV-PASSWORD</password>
</server>

<server>
  <id>nexus-releases</id>
  <username>nx-dev</username>
  <password>NX-DEV-PASSWORD</password>
</server>

In my projects POM file:

<distributionManagement>
    <snapshotRepository>
        <id>nexus-snapshots</id>
        <url>https://nexus.mysite.com/repository/maven-snapshots/</url>
    </snapshotRepository>
    <repository>
        <id>nexus-releases</id>
        <url>https://nexus.mysite.com/repository/maven-releases/</url>
    </repository>
</distributionManagement>

When I run mvn -X deploy command, I get this error:

Failed to transfer file https://nexus.mysite.com/repository/maven-releases/com/myapp/my-app/0.0.3/myapp-0.0.3.jar  with status code 400

The jar file size is 47MB that is much less than 1G allowed in Nginx:

client_max_body_size 1G;

When I browse my repositories, I can see .pom, .pom.md5 and .pom.sha1 files but there is no jar file uploaded. Any idea?

EDIT:

In nexus log I see this warning:

2020-11-16 10:00:59,843+0000 WARN  [qtp1621258076-423]  
nx-payware org.sonatype.nexus.repository.view.handlers.ExceptionHandler - Invalid content: 
PUT /com/myapp/my-app/0.0.3-SNAPSHOT/my-app-0.0.3-20201116.095741-1.jar: 
org.sonatype.nexus.repository.InvalidContentException: 
Detected content type [application/x-sh], but expected [application/java-archive]: 
/com/myapp/my-app/0.0.3-SNAPSHOT/my-app-0.0.3-20201116.095741-1.jar

Solution

  • Spring boot executable jar files are being detected as a shell script. Disable file content validation in the hosted repository in order to work around it.

    Uncheck Strict Content Type Validation:

    enter image description here