You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by "Beat Hörmann (Jira)" <ji...@apache.org> on 2022/08/17 14:45:00 UTC
[jira] [Commented] (FOP-2861) Allow resource loading from jar: URI
[ https://issues.apache.org/jira/browse/FOP-2861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17580823#comment-17580823 ]
Beat Hörmann commented on FOP-2861:
-----------------------------------
Simon, your first example is the workaround we found: Pass the custom resource resolver rr to the factory builder and again to the font-manager. Fop 2.6 didn't require the latter and the reason is not clear why 2.7 requires it (compare for question of intim96 in the last paragraph of his comment - 01/Mar/22 22:14 of FOP-3054 ). Your second example uses the EnvironmentalProfile, and, as you stated, does not involve the font-manager. It is shorter but I have problems understanding it because it requires me to know what an environment with a restrictive IO is - something I'm not aware I need. It's fine for me to adapt to the fact that in Fop 2.7 I have to pass the resource resolver twice - not very nice but for me no problem.
However, the topic of _this_ thread is that FOP learns to deal with URIs pointing into a Jar _without_ having to pass a custom resource resolver especially for this purpose. (It's my fault that these two different topics were mixed up here. The reason is that I actually could get rid of my custom resource resolver and the mentioned difference between 2.6 and 2.7 if this thread was resolved as Ole and me suggested.)
> Allow resource loading from jar: URI
> ------------------------------------
>
> Key: FOP-2861
> URL: https://issues.apache.org/jira/browse/FOP-2861
> Project: FOP
> Issue Type: Improvement
> Affects Versions: 2.0, 2.1, 2.2, 2.3, 2.4, 2.6, 2.7
> Reporter: Ole Sandum
> Priority: Major
> Attachments: FopResourceResolver.java, uri_resolve-1.diff, uri_resolve.diff, uri_resolve_decoded.diff
>
>
> 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.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)