Uploaded image for project: 'FOP'
  1. FOP
  2. FOP-2861

[PATCH] Allow resource loading from jar: URI

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0, 2.1, 2.2, 2.3, 2.4, 2.6, 2.7
    • 2.8
    • None
    • None
    • Patch

    Description

      We would like to load our FOP config.xml along with related fonts and hyphenation files using  the common classloader URL, e.g.:

        URL configXml = getClass().getResource("config.xml");
        FopConfParser confParser = 
            new FopConfParser(configXml.openStream(), configXml.toURI());

      This makes for easy deployment, and works nicely as long as classes and resources are loaded from separate files, i.e. from file:/some/path/config.xml URIs. However, it fails when classes and resources are packaged and loaded directly from a jar, i.e. from jar:file:/some/archive.jar!/path/config.xml URIs, as is the case when deploying with JWS or running an all-in-one executable jar, as it will fail to properly resolve the related font and hyphenation file URIs. 

      See https://github.com/osandum/fop-test.git for a test to illustrate.

      This is a consequence of a long standing issue (reported in https://bugs.openjdk.java.net/browse/JDK-8020755) that URI.resolve(childUri) doesn't work as expected on jar:file: URIs.

      In this case, it can be easily remedied by a work-around to the call in InternalResourceResolver.resolveFromBase(URI uri). Patch attached.

      Attachments

        1. uri_resolve-1.diff
          1 kB
          Ole Sandum
        2. uri_resolve.diff
          2 kB
          Ole Sandum
        3. uri_resolve_decoded.diff
          2 kB
          David Shepherdson
        4. LoadFromJar.java
          2 kB
          Simon Steiner
        5. FopResourceResolver.java
          1 kB
          Yannick SAVANIER

        Issue Links

          Activity

            People

              ssteiner Simon Steiner
              osandum Ole Sandum
              Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: