1

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
Ali Behzadian Nejad
  • 8,804
  • 8
  • 56
  • 106
  • Code 400 means in Nexus that the artifacts already have been uploaded before ... Releases are immutable... so you have to make a new version. Furthermore the thing you given `/com/myapp/0.0.3/myapp-0.0.1.jar...` looks wrong... – khmarbaise Nov 16 '20 at 09:43
  • Redeployment is allowed for both repositories and if I remove all artifacts from repositories and start again, I get the same results. All related files uploaded but no jar file. – Ali Behzadian Nejad Nov 16 '20 at 09:55
  • Can you please show your pom file ...Do you have an nginx in front of nexus? If so why ? have you tried to remove nginx and directly accessing Nexus? Have you checked the logs of Nexus and the logs of nginx? – khmarbaise Nov 16 '20 at 10:05
  • Nginx log was OK but in nexus log, I got a warning. I updated the question. – Ali Behzadian Nejad Nov 16 '20 at 11:01
  • First this is a SNAPSHOT and not a release anymore ... have you checked the jar file? Can you do `unzip -t JARFILE`? And please add your pom file... – khmarbaise Nov 16 '20 at 11:23

1 Answers1

2

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

Ali Behzadian Nejad
  • 8,804
  • 8
  • 56
  • 106