New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NullPointerException in com.xmlcalabash.util.XProcURIResolver #35
Comments
I believe XSLFormatter.run does include the underlying exception:
If you can provide a complete pipeline that demonstrates the NPE problem, I'll see what I can do. I'm not sure what the right semantic is when the base is null. |
Hi Norm, About wrapping the original exception, I was referring to this part of the XSLFormatter:
About the approach in the XProcURIResolver when the base is NULL, the Xerces URI Resolver has the code something like: Regards, |
Ah. Ok. I'd already reworked part of that code in XSLFormatter which partially corrected the problem. I improved it some more :-) And I attempted to do the Xerces compatible thing in resolve() |
Thanks, Norm. |
I hope this is fixed now. Please reopen if it isn't. |
I have an XProc with code like this:
.................
<p:xsl-formatter content-type="application/pdf">
<p:with-option name="href" select="$pdf-file"></p:with-option>
<p:with-param name="UserConfig" select="$fop-config"/>
</p:xsl-formatter>
...................
which tries to generate PDF using Apache FOP.
The FOP configuration file looks like this:
<fop version="1.0">
<accessibility>true</accessibility>
<target-resolution>240</target-resolution>
<renderers>
<renderer mime="application/pdf">
<fonts>
<auto-detect/>
</fonts>
</renderer>
</renderers>
</fop>
When transforming, the output fails with a message like:
Failed to process FO document with FOP null
which is actually generated by:
Caused by: java.lang.NullPointerException
at java.net.URI$Parser.parse(Unknown Source)
at java.net.URI.(Unknown Source)
at com.xmlcalabash.util.XProcURIResolver.resolve(Unknown Source)
at org.apache.fop.apps.FOURIResolver.resolve(FOURIResolver.java:179)
at org.apache.fop.apps.FopFactory.resolveURI(FopFactory.java:753)
at org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:425)
at org.apache.fop.render.DefaultFontResolver.resolve(DefaultFontResolver.java:44)
at org.apache.fop.fonts.FontLoader.openFontUri(FontLoader.java:154)
at org.apache.fop.fonts.truetype.TTFFontLoader.read(TTFFontLoader.java:94)
at org.apache.fop.fonts.truetype.TTFFontLoader.read(TTFFontLoader.java:84)
at org.apache.fop.fonts.FontLoader.getFont(FontLoader.java:190)
at org.apache.fop.fonts.FontLoader.loadFont(FontLoader.java:139)
at org.apache.fop.fonts.LazyFont.load(LazyFont.java:134)
at org.apache.fop.fonts.LazyFont.getAscender(LazyFont.java:241)
at org.apache.fop.fonts.Font.getAscender(Font.java:106)
at org.apache.fop.layoutmgr.BlockLayoutManager.initialize(BlockLayoutManager.java:87)
at org.apache.fop.layoutmgr.AbstractLayoutManager.getChildLM(AbstractLayoutManager.java
So the method:
public Source resolve(String href, String base) throws TransformerException {
receives a NULL base from Apache FOP and tries to make an URI out of it:
URIResolver(file:/C:/Windows/FONTS/arial.ttf,null)
So you should take into account on the URIResolver the possibility of a NULL base.
The workaround is simple, a "./" can be specified in the configuration file in order for Apache FOP to also specify the base in the URI resolver and avoid the NPE.
One more improvement which would help debug such cases would be that in the method:
com.xmlcalabash.library.XSLFormatter.run()
when an exception is caught, it should not be ignored but instead be provided as the cause of the thrown XProcException.
The text was updated successfully, but these errors were encountered: