[ https://issues.apache.org/jira/browse/FOP-3109?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17636349#comment-17636349 ]
Matteo Franci commented on FOP-3109: ------------------------------------ After further investigation, it appears the different behaviour was introduced at line 311 of [FopFactoryBuilder|[http://example.com](https://github.com/apache/xmlgraphics-fop/blob/fop-2_8/fop-core/src/main/java/org/apache/fop/apps/FopFactoryBuilder.java)|http://example.com]%28https//github.com/apache/xmlgraphics-fop/blob/fop-2_8/fop-core/src/main/java/org/apache/fop/apps/FopFactoryBuilder.java)] : {code:java} protected FopFactoryBuilder setConfiguration(Configuration cfg, boolean parse) { fopFactoryConfigBuilder.setConfiguration(cfg); if (parse) { try { new FopConfParser(cfg, this); } catch (SAXException e) { throw new RuntimeException(e); } } return this; } {code} The construction of the [FopConfParser]([https://github.com/apache/xmlgraphics-fop/blob/trunk/fop-core/src/main/java/org/apache/fop/apps/FopConfParser.java)] at line 164 invoke the configure with a new default ResourceResolver instead of the custom set in FopFactoryBuilder {code:java} public FopConfParser(Configuration cfg, FopFactoryBuilder fopFactoryBuilder) throws SAXException { this.fopFactoryBuilder = fopFactoryBuilder; configure(fopFactoryBuilder.getBaseURI(), ResourceResolverFactory.createDefaultResourceResolver(), cfg); } {code} And at line to 294 override the ResourseResolver for the FontManager with the default one : {code:java} // configure font manager new FontManagerConfigurator(cfg, baseURI, fopFactoryBuilder.getBaseURI(), resourceResolver) .configure(fopFactoryBuilder.getFontManager(), strict); {code} (All line number reference are for version 2.8 of Apache FOP). A possible work around has been committed on the POC repository : https://github.com/fugerit79/fop-custom-resource-resolver-poc/commit/d2f8ec60b69d160442c16025ba4aff9c99c863a1 > Custom ResourceResolver seems to be ignored in version 2.7+ > ----------------------------------------------------------- > > Key: FOP-3109 > URL: https://issues.apache.org/jira/browse/FOP-3109 > Project: FOP > Issue Type: Bug > Components: renderer/pdf, unqualified > Affects Versions: 2.7, 2.8 > Environment: Tested on : > JDK 1.8.0_333 and JDK 11.0.16 > Apache Maven 3.8.6 > Windows 10 and Ubuntu 22.04 > Reporter: Matteo Franci > Priority: Major > > It's the first time I open an issue on Apache JIRA. I read the guidelines but > I hope I did not make mistakes. > When creating a FopFactory with a custom ResourceResolver, the resolver seems > to be ignored in Apache FOP 2.7 e 2.8. > The same code apperead to work properly in Apache FOP 2.6. > {code:java} > ResourceResolver resolver = new ClassLoaderResourceResolver(); > FopFactoryBuilder builder = new FopFactoryBuilder(new > File(".").toURI(), resolver ); > builder = builder.setConfiguration(new > DefaultConfigurationBuilder().build(fopConfigStream)); > FopFactory fopFactory = builder.build(); {code} > > Here is a proof of concept with a custom ResourceResolver loading font from > the class loader when the path starts with classpath:// > [https://github.com/fugerit79/fop-custom-resource-resolver-poc] -- This message was sent by Atlassian Jira (v8.20.10#820010)