Project

Profile

Help

Bug #4975

Null pointer exception when XSLT 3.0 run from the command line

Added by Graydon Saunders 25 days ago. Updated 5 days ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
Diagnostics
Sprint/Milestone:
-
Start date:
2021-04-22
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
10, trunk
Fix Committed on Branch:
10, trunk
Fixed in Maintenance Release:

Description

in oXygen ( XML Editor 23.1, build 2021040908) with the 10.3 external add-on, the transform (small.xsl) works. oXygen 23 uses a Java 15 JRE

17:40 bin % ./java --version openjdk 15.0.1 2020-10-20 OpenJDK Runtime Environment (build 15.0.1+9-18) OpenJDK 64-Bit Server VM (build 15.0.1+9-18, mixed mode)

If I try to call small.xsl from the shell (Linux; Fedora 33, bash 5.0.17) using small.sh, I get a null pointer error.

I believe I have exhausted my ingenuity on this one and have a minimal example which I would prefer to send under separate cover.

The code from which the minimal example has been extracted has been working fine in oXygen; the minimal example itself runs fine in oXygen. Trying to run it from the command line for automated testing purposes hasn't made it past the null pointer error. Various other transforms run fine, Saxon finds the license OK, etc. I get what I think is the same error with Saxon 10.3 and 10.5, and with Java 11 and Java 16.

15:48 tests % java --version openjdk 11.0.10 2021-01-19 OpenJDK Runtime Environment 18.9 (build 11.0.10+9) OpenJDK 64-Bit Server VM 18.9 (build 11.0.10+9, mixed mode, sharing)

15:54 tests % /etc/alternatives/java_sdk_16/bin/java --version openjdk 16 2021-03-16 OpenJDK Runtime Environment 21.3 (build 16+36) OpenJDK 64-Bit Server VM 21.3 (build 16+36, mixed mode, sharing)

Stack Trace: 17:42 tests % ./small.sh (DITA2Word)-[one-githubTests-gds] java.lang.NullPointerException at java.base/java.util.Objects.requireNonNull(Objects.java:221) at net.sf.saxon.trans.XmlProcessingIncident.(XmlProcessingIncident.java:52) at net.sf.saxon.Controller.warning(Controller.java:469) at net.sf.saxon.resource.XmlResource.getItem(XmlResource.java:162) at net.sf.saxon.resource.UnknownResource.getItem(UnknownResource.java:88) at net.sf.saxon.resource.MetadataResource.lambda$getItem$0(MetadataResource.java:64) at net.sf.saxon.functions.CallableFunction.call(CallableFunction.java:128) at net.sf.saxon.functions.SystemFunction.dynamicCall(SystemFunction.java:459) at net.sf.saxon.functions.ApplyFn.call(ApplyFn.java:166) at net.sf.saxon.expr.FunctionCall.iterate(FunctionCall.java:548) at net.sf.saxon.expr.CardinalityChecker.evaluateItem(CardinalityChecker.java:283) at net.sf.saxon.expr.ItemChecker.evaluateItem(ItemChecker.java:255) at net.sf.saxon.expr.parser.Evaluator$5.evaluate(Evaluator.java:151) at net.sf.saxon.expr.parser.Evaluator$5.evaluate(Evaluator.java:148) at net.sf.saxon.expr.UserFunctionCall.evaluateArguments(UserFunctionCall.java:662) at net.sf.saxon.expr.UserFunctionCall.evaluateArguments(UserFunctionCall.java:644) at net.sf.saxon.expr.UserFunctionCall.callFunction(UserFunctionCall.java:534) at net.sf.saxon.expr.UserFunctionCall.evaluateItem(UserFunctionCall.java:491) at net.sf.saxon.expr.LookupExpression.iterate(LookupExpression.java:337) at net.sf.saxon.expr.parser.Evaluator$7.evaluate(Evaluator.java:199) at net.sf.saxon.expr.SystemFunctionCall.evaluateArguments(SystemFunctionCall.java:454) at net.sf.saxon.expr.FunctionCall.iterate(FunctionCall.java:546) at net.sf.saxon.expr.instruct.ForEach.map(ForEach.java:584) at net.sf.saxon.expr.ContextMappingIterator.next(ContextMappingIterator.java:61) at net.sf.saxon.om.FocusTrackingIterator.next(FocusTrackingIterator.java:76) at net.sf.saxon.om.SequenceIterator.forEachOrFail(SequenceIterator.java:135) at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:526) at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:142) at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:352) at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:298) at com.saxonica.ee.bytecode.ByteCodeCandidate.processLeavingTail(ByteCodeCandidate.java:185) at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:264) at net.sf.saxon.trans.XsltController.callTemplate(XsltController.java:850) at net.sf.saxon.s9api.Xslt30Transformer.callTemplate(Xslt30Transformer.java:480) at net.sf.saxon.Transform.processFile(Transform.java:1306) at net.sf.saxon.Transform.doTransform(Transform.java:853) at net.sf.saxon.Transform.main(Transform.java:82) Fatal error during transformation: java.lang.NullPointerException: (no message)

History

#1 Updated by Michael Kay 25 days ago

It's a little bit puzzling because there is no call to Controller.warning() at UnknownResource.getItem()(UnknownResource.java:88), however, I can see several calls to Controller.warning() (in CatalogCollection, DirectoryCollection, and XmlResource) that will trigger this crash because they set the location parameter to null.

All three of these warnings are triggered when you specify on-error=warning in the query parameters of a collection URI, so as a workaround, try locating this and changing it to on-error=ignore or on-error=fail.

The fact that there's an UnknownResource means that Saxon wasn't able to decide what kind of resource it would get (e.g. XML, JSON, binary, etc) from the filename/URI alone, probably because there was no file extension. You might also find you can avoid the problem by using something like select=*.xml in the collection URI to select only those resources with a known file extension.

#2 Updated by Michael Kay 25 days ago

Thanks for sending the repro (offline). Sure enough, line 85 uses on-error=warning, so changing that should enable you to make progress while we fix the bug.

#3 Updated by Graydon Saunders 25 days ago

Thanks for sending the repro (offline). Sure enough, line 85 uses on-error=warning, so changing that should enable you to make progress while we fix the bug.

on-error=ignore continues to produce a null-pointer exception;
on-error=fail fails politely on a specific file, which I can certainly
fix.

Thank you; gets me unstuck.

On Thu, Apr 22, 2021 at 07:20:45PM +0200, Saxonica Developer Community scripsit:

#4 Updated by Michael Kay 5 days ago

  • Category set to Diagnostics
  • Status changed from New to Resolved
  • Applies to branch trunk added
  • Fix Committed on Branch 10, trunk added

I have changed Controller.warning() so that it tolerates any of the three arguments (message, errorCode, location) being null.

Please register to edit this issue

Also available in: Atom PDF