Uploaded image for project: 'Dev - Nexus Repo'
  1. Dev - Nexus Repo
  2. NEXUS-3972

Content-Type problems mirroring XML based artifacts between nexus instances

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 1.9
    • 1.8
    • Repository
    • None
    • 1

    Description

      Based on the email thread I started on the Nexus mailing list, I'm raising this as a ticket regarding problems setting a Nexus->Nexus mirror and dealing with XML based artifacts repository artifacts.

      After some packet sniffing and testing I found that requesting our Karaf feature file, which is a XML based artifact with a classifier:

      curl -v http://remote:8081/nexus/content/repositories/smxmavenrepo/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml

      > GET /nexus/content/repositories/smxmavenrepo/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml HTTP/1.1
      > User-Agent: curl/7.21.2 (x86_64-apple-darwin10.4.0) libcurl/7.21.2 OpenSSL/1.0.0b zlib/1.2.5 libidn/1.19
      > Host: in1sec03.smx.co.in:8081
      > Accept: */*
      >
      < HTTP/1.1 404 Not Found
      < Date: Mon, 29 Nov 2010 21:16:47 GMT
      < Expires: Thu, 01 Jan 1970 00:00:00 GMT
      < Set-Cookie: JSESSIONID=ggosgpjdy2y2;Path=/nexus
      < Content-Type: text/html; charset=ISO-8859-1
      < Date: Mon, 29 Nov 2010 21:16:47 GMT
      < Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept
      < Server: Noelios-Restlet-Engine/1.1.6-SONATYPE-5348-V4
      < Content-Length: 330
      

      I get a 404 and no upstream is checked, however when requesting an a jar artifact for the same thing:

      curl -v http://remote:8081/nexus/content/repositories/smxmavenrepo/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27.jar

      > GET /nexus/content/repositories/smxmavenrepo/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27.jar HTTP/1.1
      > User-Agent: curl/7.21.2 (x86_64-apple-darwin10.4.0) libcurl/7.21.2 OpenSSL/1.0.0b zlib/1.2.5 libidn/1.19
      > Host: in1sec03.smx.co.in:8081
      > Accept: */*
      >
      < HTTP/1.1 200 OK
      < Date: Mon, 29 Nov 2010 21:16:27 GMT
      < Expires: Thu, 01 Jan 1970 00:00:00 GMT
      < Set-Cookie: JSESSIONID=y3ymmt2jubxu;Path=/nexus
      < Content-Type: application/java-archive
      < Last-Modified: Fri, 12 Nov 2010 03:15:41 GMT
      < ETag: "6e29e9e66c27605036fce871da6429ec70099435"
      < Date: Mon, 29 Nov 2010 21:16:37 GMT
      < Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept
      < Server: Noelios-Restlet-Engine/1.1.6-SONATYPE-5348-V4
      < Content-Length: 908770
      .....binary data here.....
      

      This led to me think there was something about the content type of the artifact, and after putting the nexus logging into DEBUG I see the following:

      2010-11-29 21:29:06 DEBUG [27-features.xml] - o.s.n.p.s.l.f.Defau~ - /smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml --> /smx/nexus/repository/smx/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml
      2010-11-29 21:29:06 DEBUG [27-features.xml] - o.s.n.i.DefaultInde~ - The ArtifactContext created from file is fine, continuing.
      2010-11-29 21:29:06 DEBUG [27-features.xml] - o.s.n.p.r.v.Default~ - Checking if file:
      /smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml is of one of the types: [text/xml]
      2010-11-29 21:29:06 DEBUG [27-features.xml] - e.m.m.MimeUtil2  - Getting MIME types for InputSteam [java.io.BufferedInputStream@689cf670].
      2010-11-29 21:29:06 DEBUG [27-features.xml] - e.m.m.MimeUtil2  - Retrieved MIME types [application/octet-stream]
      2010-11-29 21:29:06 DEBUG [27-features.xml] - o.s.n.p.r.v.Default~ - Expected mime types: [text/xml], Actual mime types: application/octet-stream
      2010-11-29 21:29:06 DEBUG [27-features.xml] - o.s.n.p.m.m.M2Repos~ - Using mirror URL:http://build.smx.co.nz:8081/nexus/content/groups/public/,retryCount=10
      2010-11-29 21:29:06 DEBUG [27-features.xml] - o.s.n.p.s.r.c.Commo~  - Invoking HTTP GET method against remote location http://build.smx.co.nz:8081/nexus/content/groups/public/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.p.m.m.M2Repos~ - Caching item smxmavenrepo:/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml in local storage of repository.
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.p.s.l.f.Defau~ - /smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml --> /smx/nexus/repository/smx/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.p.s.l.f.Defau~ - /smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml --> /smx/nexus/repository/smx/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.p.s.l.f.Defau~  - Copying stream with buffer size of: 4096
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.p.a.DefaultAt~ - Storing attributes on UID=smxmavenrepo:/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.p.m.m.M2Repos~ - Removing path /smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml from NFC.
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.p.s.l.f.Defau~ - /smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml --> /smx/nexus/repository/smx/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml
      2010-11-29 21:29:07 DEBUG [27-features.xml] - e.m.m.MimeUtil2  - Getting MIME types for file [/smx/nexus/repository/smx/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml].
      2010-11-29 21:29:07 DEBUG [27-features.xml] - e.m.m.MimeUtil2  - Retrieved MIME types [text/xml,application/xml]
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.p.a.DefaultAt~ - Loading attributes on UID=smxmavenrepo:/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.p.a.DefaultAt~ - Storing attributes on UID=smxmavenrepo:/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.p.a.SimpleAppli~ - Notifying 18 EventListener about event org.sonatype.nexus.proxy.events.RepositoryItemEventCache fired (org.sonatype.nexus.proxy.events.RepositoryItemEventCache@203d793)
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.p.s.l.f.Defau~ - /smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml --> /smx/nexus/repository/smx/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.i.DefaultInde~  - The ArtifactContext created from file is fine, continuing.
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.p.r.v.Default~  - Checking if file: /smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml is of one of the types: [text/xml]
      2010-11-29 21:29:07 DEBUG [27-features.xml] - e.m.m.MimeUtil2 - Getting MIME types for InputSteam [java.io.BufferedInputStream@4a3df4ed].
      2010-11-29 21:29:07 DEBUG [27-features.xml] - e.m.m.MimeUtil2  - Retrieved MIME types [application/octet-stream]
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.p.r.v.Default~  - Expected mime types: [text/xml], Actual mime types: application/octet-stream
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.p.m.m.M2Repos~  - Item /smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml failed content integrity validation.
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.p.s.l.f.Defau~  - /smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml --> /smx/nexus/repository/smx/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml
      2010-11-29 21:29:07 DEBUG [27-features.xml] - e.m.m.MimeUtil2 - Getting MIME types for file [/smx/nexus/repository/smx/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml].
      2010-11-29 21:29:07 DEBUG [27-features.xml] - e.m.m.MimeUtil2 - Retrieved MIME types [text/xml,application/xml]
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.p.a.DefaultAt~ - Loading attributes on UID=smxmavenrepo:/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.p.a.DefaultAt~ - Storing attributes on UID=smxmavenrepo:/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.p.a.DefaultAt~ - Deleting attributes on UID=smxmavenrepo:/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.p.s.l.f.Defau~  - /smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml --> /smx/nexus/repository/smx/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.p.m.m.M2Repos~ - Item /smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml not found in remote storage.
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.p.m.m.M2Repos~ - Item /smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml does not exist in local storage neither in remote storage, throwing ItemNotFoundException.
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.p.m.m.M2Repos~  - smxmavenrepo retrieveItem() :: NOT FOUND smxmavenrepo:/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml
      2010-11-29 21:29:07 DEBUG [27-features.xml] - o.s.n.p.m.m.M2Repos~  - Adding path /smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml to NFC.
      2010-11-29 21:29:07 ERROR [27-features.xml] - o.s.n.r.ContentPlex~  - Got exception during processing request "GET http://in1sec03.smx.co.in:8081/nexus/content/repositories/smxmavenrepo/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml": Item not found on path "/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml" in repository "smxmavenrepo"!
      2010-11-29 21:29:07 DEBUG [27-features.xml] - org.mortbay.log - RESPONSE /nexus/content/repositories/smxmavenrepo/smx3/smx3.demobrands/3.0.27/smx3.demobrands-3.0.27-features.xml  404
      2010-11-29 21:29:07 DEBUG [p-880484842-103] - org.mortbay.log - EOF
      

      So it looks like my LOCAL Nexus ( 1.5 ) isn't sending the correct Content-Type headers for the XML files, and the remote Nexus is rejecting it. The local nexus appears to be sending "application/xml", but it looks like the remote nexus wants "text/xml" when checking the incoming InputStream. Looking at the Nexus JIRA I see NEXUS-2416 [1] and NEXUS-2688 [2] related to Content-Type issues, as mentioned in NEXUS-2688 I added a mime-types.properties file to my local Nexus to send out .xml files as text/xml ( and saw that coming out fine ), expired the remote servers cache and saw it get the same problems as the original request without any change.

      The problem looks to be in AbstractFileTypeValidator#isExpectedFileType when Nexus calls out to eu.medsea.mimeutil.MimeUtil2, I wonder if wrapping the InputStream with a BufferedInputStream is triggering MimeUtil2 to only see the stream as an octet/stream rather than what it should be?

      Hopefully there's enough info here for someone to make an informed response - shall I raise this entire email into a JIRA ticket?

      Mark

      [1] https://issues.sonatype.org/browse/NEXUS-2416
      [2] https://issues.sonatype.org/browse/NEXUS-2688

      Attachments

        Activity

          People

            rseddon Rich Seddon
            talios Mark Derricutt
            Peter Lynch Peter Lynch
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              tigCommentSecurity.panel-title