Uploaded image for project: 'Runtime'
  1. Runtime
  2. RUNTIME-3875

Custom protocols are no more usable in fop-user-config.xml

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • 4.8.0, 4.7.3
    • 4.8.0, 4.7.2
    • None
    • None
    • 4.8.0 M3

      Steps to reproduce

      Create a fop-user-config.xml with a font URL containing a custom protocol (like plugin) :

      <font kerning="yes" embed-url="plugin:myplugin://fonts/MyFont.ttf">
          <font-triplet name="MyFont" style="normal" weight="normal"/>
      </font>

      Try to generate a PDF.

      You should get this error:

      [...]
      Caused by: org.apache.commons.lang.exception.NestableRuntimeException: javax.xml.transform.TransformerException: java.lang.RuntimeException: Failed to read font file plugin:myplugin://fonts/MyFont.ttf unknown protocol: plugin
      	at org.apache.cocoon.transformation.TraxTransformer.endDocument(TraxTransformer.java:604)
      	at org.apache.xml.serializer.ToXMLSAXHandler.endDocument(ToXMLSAXHandler.java:183)
      	at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1369)
      	at org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:3449)
      	at org.apache.xalan.transformer.TransformerHandlerImpl.endDocument(TransformerHandlerImpl.java:408)
      	at org.apache.cocoon.xml.AbstractXMLPipe.endDocument(AbstractXMLPipe.java:56)
      	at org.apache.cocoon.transformation.TraxTransformer.endDocument(TraxTransformer.java:586)
      	at fr.ametys.myproject.service.AbstractSearchGenerator.generate(AbstractSearchGenerator.java:103)
      	at org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.processXMLPipeline(AbstractProcessingPipeline.java:581)
      	... 98 more
      Caused by: javax.xml.transform.TransformerException: java.lang.RuntimeException: Failed to read font file plugin:myplugin://fonts/MyFont.ttf unknown protocol: plugin
      	at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2407)
      	at org.apache.xalan.templates.ElemTemplate.execute(ElemTemplate.java:394)
      	at org.apache.xalan.templates.ElemCallTemplate.execute(ElemCallTemplate.java:248)
      	at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2402)
      	at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:1376)
      	at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395)
      	at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:178)
      	at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2402)
      	at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2272)
      	at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1358)
      	at org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:3449)
      	at org.apache.xalan.transformer.TransformerHandlerImpl.endDocument(TransformerHandlerImpl.java:408)
      	at org.apache.cocoon.xml.AbstractXMLPipe.endDocument(AbstractXMLPipe.java:56)
      	at org.apache.cocoon.transformation.TraxTransformer.endDocument(TraxTransformer.java:586)
      	... 106 more
      Caused by: java.lang.RuntimeException: Failed to read font file plugin:myplugin://fonts/MyFont.ttf unknown protocol: plugin
      	at org.apache.fop.fonts.LazyFont.load(LazyFont.java:134)
      	at org.apache.fop.fonts.LazyFont.getAscender(LazyFont.java:237)
      	at org.apache.fop.fonts.Font.getAscender(Font.java:120)
      	at org.apache.fop.layoutmgr.BlockLayoutManager.initialize(BlockLayoutManager.java:82)
      	at org.apache.fop.layoutmgr.AbstractLayoutManager.getChildLM(AbstractLayoutManager.java:118)
      	at org.apache.fop.layoutmgr.table.TableCellLayoutManager.getNextKnuthElements(TableCellLayoutManager.java:184)
      	at org.apache.fop.layoutmgr.table.RowGroupLayoutManager.createElementsForRowGroup(RowGroupLayoutManager.java:120)
      	at org.apache.fop.layoutmgr.table.RowGroupLayoutManager.getNextKnuthElements(RowGroupLayoutManager.java:63)
      	at org.apache.fop.layoutmgr.table.TableContentLayoutManager.getKnuthElementsForRowIterator(TableContentLayoutManager.java:270)
      	at org.apache.fop.layoutmgr.table.TableContentLayoutManager.getNextKnuthElements(TableContentLayoutManager.java:212)
      	at org.apache.fop.layoutmgr.table.TableLayoutManager.getNextKnuthElements(TableLayoutManager.java:277)
      	at org.apache.fop.layoutmgr.FlowLayoutManager.getNextChildElements(FlowLayoutManager.java:223)
      	at org.apache.fop.layoutmgr.FlowLayoutManager.addChildElements(FlowLayoutManager.java:148)
      	at org.apache.fop.layoutmgr.FlowLayoutManager.getNextKnuthElements(FlowLayoutManager.java:116)
      	at org.apache.fop.layoutmgr.FlowLayoutManager.getNextKnuthElements(FlowLayoutManager.java:69)
      	at org.apache.fop.layoutmgr.PageBreaker.getNextKnuthElements(PageBreaker.java:252)
      	at org.apache.fop.layoutmgr.AbstractBreaker.getNextBlockList(AbstractBreaker.java:675)
      	at org.apache.fop.layoutmgr.PageBreaker.getNextBlockList(PageBreaker.java:179)
      	at org.apache.fop.layoutmgr.PageBreaker.getNextBlockList(PageBreaker.java:159)
      	at org.apache.fop.layoutmgr.AbstractBreaker.doLayout(AbstractBreaker.java:385)
      	at org.apache.fop.layoutmgr.PageBreaker.doLayout(PageBreaker.java:113)
      	at org.apache.fop.layoutmgr.PageSequenceLayoutManager.activateLayout(PageSequenceLayoutManager.java:143)
      	at org.apache.fop.area.AreaTreeHandler.endPageSequence(AreaTreeHandler.java:267)
      	at org.apache.fop.fo.DelegatingFOEventHandler.endPageSequence(DelegatingFOEventHandler.java:114)
      	at org.apache.fop.accessibility.fo.FO2StructureTreeConverter.endPageSequence(FO2StructureTreeConverter.java:184)
      	at org.apache.fop.fo.pagination.PageSequence.endOfNode(PageSequence.java:140)
      	at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement(FOTreeBuilder.java:390)
      	at org.apache.fop.fo.FOTreeBuilder$3.run(FOTreeBuilder.java:207)
      	at org.apache.fop.fo.FOTreeBuilder$3.run(FOTreeBuilder.java:204)
      	at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
      	at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:203)
      	at org.apache.cocoon.xml.AbstractXMLPipe.endElement(AbstractXMLPipe.java:112)
      	at org.apache.cocoon.components.EnvironmentChanger.endElement(EnvironmentStack.java:148)
      	at org.apache.cocoon.xml.AbstractXMLPipe.endElement(AbstractXMLPipe.java:112)
      	at org.apache.cocoon.transformation.I18nTransformer.endElement(I18nTransformer.java:1222)
      	at org.apache.xml.serializer.ToXMLSAXHandler.endElement(ToXMLSAXHandler.java:263)
      	at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:1401)
      	at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2402)
      	... 119 more
      Caused by: java.net.MalformedURLException: unknown protocol: plugin
      	at java.base/java.net.URL.<init>(URL.java:681)
      	at java.base/java.net.URL.fromURI(URL.java:748)
      	at java.base/java.net.URI.toURL(URI.java:1139)
      	at org.apache.fop.apps.io.ResourceResolverFactory$NormalResourceResolver.getResource(ResourceResolverFactory.java:224)
      	at org.apache.fop.apps.io.ResourceResolverFactory$TempAwareResourceResolver.getResource(ResourceResolverFactory.java:152)
      	at org.apache.fop.apps.io.ResourceResolverFactory$DefaultResourceResolver.getResource(ResourceResolverFactory.java:121)
      	at org.apache.fop.apps.io.InternalResourceResolver.getResource(InternalResourceResolver.java:92)
      	at org.apache.fop.fonts.truetype.OFFontLoader.read(OFFontLoader.java:113)
      	at org.apache.fop.fonts.truetype.OFFontLoader.read(OFFontLoader.java:103)
      	at org.apache.fop.fonts.FontLoader.getFont(FontLoader.java:126)
      	at org.apache.fop.fonts.FontLoader.loadFont(FontLoader.java:110)
      	at org.apache.fop.fonts.LazyFont.load(LazyFont.java:121)
      	... 156 more

      Analyze

      Custom resolver is ignored by FopFactoryBuilder when adding a custom configuration (https://issues.apache.org/jira/browse/FOP-3109).
      To avoid this, there is a workaround described here: https://github.com/fugerit79/fop-custom-resource-resolver-poc/commit/d2f8ec60b69d160442c16025ba4aff9c99c863a1

      Since: 4.6 (FOP 2.7 and more)

            bmaurel Bérénice Maurel
            bmaurel Bérénice Maurel
            Bérénice Maurel Bérénice Maurel
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: