Uploading Artifacts

I am trying to upload Snapshot.jar file to nexus and I am getting this error.

Return code is: 400, ReasonPhrase: Detected content type [application/x-sh], but expected [application/java-archive]:

When I change the file to tar extension successfully uploaded. Do you have any idea about this error?

Thank you,

The uploaded jar is being detected as a shell script. Is this a spring boot jar by any chance? If so, this is a known issue. Disable file content validation in the hosted repository in order to work around it.

1 Like

Thank you so much for your support. Mentioned solution works.

@rseddon why not make it configuarable, whitelist some mime types etc.

I’ve seen in DefaultMimeSupport that you derive the content-type using Apache Tika based on the file’s content and filename.

For an executable jar, Tika indeed returns application/x-sh. But IHMO this is wrong, at least in the context of Nexus Repository. Yes, an executable jar starts with a shell script, but it’s just a wrapper to facilitate execution but doesn’t change the primary nature of the file as a Java archive. The file is primarily a JAR file and should be treated as such (application/java-archive).