Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-9021

Warning "Could not resolve Schema for datatypes.dtd" when file was found

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 4.0.4
    • 4.1.0, 3.5.10, 3.6.5, 4.0.6
    • Core
    • None
    • Moderate

    Description

      Assuming you have

      • system property javax.xml.accessExternalDTD set to all or file
      • enabled out validation
      • an xsd that references a DTD

      And fire a request, the following log appears:

      WARN [org.apa.cxf.ws.add.EndpointReferenceUtils] Could not resolve Schema for ../dtd/XMLSchema.dtd

      The request is then correctly validated, despite the warning. Tested with both valid and invalid equests.

      Looking at the code:

                  if (impl == null) {
          [...] // if found in schemas map:
                  return impl;
          if (systemId != null) {
              [...] // if found by systemId:
                      return impl;
          }
          if (namespaceURI != null) {
              [...] // if found by namespaceURI:
                      return impl;
          }
          [...]
          if (systemId == null) {
              systemId = publicId;
          }
          if (systemId != null) {
              InputSource source = resolver.resolve(systemId, baseURI);
              if (source != null) {
                  impl = new LSInputImpl();
                  impl.setByteStream(source.getByteStream());
                  impl.setSystemId(source.getSystemId());
                  impl.setPublicId(source.getPublicId());
      +            ### the code above is run, source is found, impl is set
      +            ### i miss a 'return impl;' here, to match the code above
              }
          }
          LOG.warning("Could not resolve Schema for " + systemId);
      }
      return impl;
      

      I added two inline 'comments', starting with ### to mark the place where i miss a return statement.
      Reasoning:

      1. all of the above happens in an if block: if (impl==null)
      2. it seems that with different searches eg. via namespaceURI and systemId, the variable impl should be filled and then returned
      3. the warning in the last line says 'Could not resolve Schema'
      4. but the code directly above it may indeed find a source and fill impl
      5. so the schema (in my case a DTD) is found. I can verify that by looking into debug values. And the validation then takes place, with expected outcomes.
      6. first finding the schema and then printing that it could not be found is misleading

      proposed solution:

      • either a return impl; statement like mentioned above
      • or guard the warning with if (impl==null)

      Attachments

        Activity

          People

            ffang Freeman Yue Fang
            mickroll Michael Kroll
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: