1

I am using Saxon PE 9.4 version. I am frequently getting an issue while parsing XSL but the issue is not consistent. Sometime it comes and sometime it doesn't come. Following is the stack trace:

SEVERE: java.lang.NullPointerException
   at net.sf.saxon.expr.instruct.Bindery.getGlobalVariableValue(Bindery.java:264)
   at net.sf.saxon.expr.instruct.GlobalParam.evaluateVariable(GlobalParam.java:47)
   at net.sf.saxon.expr.VariableReference.evaluateVariable(VariableReference.java:488)
   at net.sf.saxon.expr.VariableReference.iterate(VariableReference.java:441)
   at net.sf.saxon.expr.Atomizer.iterate(Atomizer.java:230)
   at net.sf.saxon.expr.AtomicSequenceConverter.iterate(AtomicSequenceConverter.java:281)
   at net.sf.saxon.expr.CardinalityChecker.evaluateItem(CardinalityChecker.java:249)
   at net.sf.saxon.expr.ItemChecker.evaluateItem(ItemChecker.java:178)
   at net.sf.saxon.expr.parser.ExpressionTool.evaluate(ExpressionTool.java:320)
   at net.sf.saxon.expr.parser.ExpressionTool.lazyEvaluate(ExpressionTool.java:434)
   at com.saxonica.expr.JavaExtensionFunctionCall.iterate(JavaExtensionFunctionCall.java:275)
   at net.sf.saxon.expr.Expression.evaluateItem(Expression.java:411)
   at net.sf.saxon.expr.AtomicSequenceConverter.evaluateItem(AtomicSequenceConverter.java:325)
   at net.sf.saxon.expr.instruct.ValueOf.evaluateItem(ValueOf.java:273)
   at net.sf.saxon.expr.instruct.SimpleNodeConstructor.iterate(SimpleNodeConstructor.java:258)
   at net.sf.saxon.expr.instruct.DocumentInstr.evaluateItem(DocumentInstr.java:302)
   at net.sf.saxon.expr.Atomizer.evaluateItem(Atomizer.java:240)
   at net.sf.saxon.expr.CastExpression.evaluateItem(CastExpression.java:320)
   at net.sf.saxon.expr.ValueComparison.effectiveBooleanValue(ValueComparison.java:682)
   at net.sf.saxon.expr.instruct.Choose.processLeavingTail(Choose.java:789)
   at net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:212)
   at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1034)
   at net.sf.saxon.Controller.transformDocument(Controller.java:1959)
   at net.sf.saxon.Controller.transform(Controller.java:1805)
   at dyngrammar.transform.TransformXSL.parseXSLT(TransformXSL.java:320)

XSLT Used :

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:request="java:common.RequestSearchCommand" exclude-result-prefixes="request">
    <xsl:output omit-xml-declaration="yes" method="xml" indent="yes"/>
    <xsl:param name="decodeFlag"/>
    <xsl:param name="requestString"/>
    <xsl:variable name="segmentName">ABC</xsl:variable>
    <xsl:variable name="searchBlbContent">(CU0 ##)|(AMIS ##)</xsl:variable>
    <xsl:template match="/">
        <xsl:variable name="matchFlag">
            <xsl:value-of select="request:searchPattren($requestString, $segmentName, $searchBlbContent, $decodeFlag)" />
        </xsl:variable>
        <xsl:choose>
            <xsl:when test="$matchFlag = 'true'">
                <xsl:copy-of select="/*" />
            </xsl:when>
            <xsl:otherwise>
                <ABC></ABC>
            </xsl:otherwise>    
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>

Please suggest how can I solve this issue.

Nitesh Gupta
  • 215
  • 1
  • 11
  • Just a guess, but it looks like your XSLT is using an invalid variable reference. Can you show us the XSLT that is producing the problem? – JLRishe Dec 30 '14 at 07:15
  • @JLRishe XSLT is not an issue because when I re run for same XSLT it runs fine. – Nitesh Gupta Dec 30 '14 at 07:20
  • Even if it runs fine sometimes, there is a very high likelihood that the error is related to your particular XSLT. So please share it. – JLRishe Dec 30 '14 at 07:45
  • @JLRishe I have updated the question with XSLT. – Nitesh Gupta Dec 30 '14 at 09:19
  • Is that your exact code? `searchPattren`? And this sometimes works? – michael.hor257k Dec 30 '14 at 09:34
  • @michael.hor257k yes this is the exact code. I am using a licensed version and search pattern is my Java method which I am calling from XSLT – Nitesh Gupta Dec 30 '14 at 09:46
  • Is there any multi-threading involved? In particular, are you perhaps using the JAXP Transformer object in more than one thread concurrently? – Michael Kay Dec 30 '14 at 18:42
  • @MichaelKay Yes multi-threading is involved. – Nitesh Gupta Dec 31 '14 at 03:35
  • 1
    Then we need to see the details of the multithreading. Note that concurrent use of a JAXP Transformer is not allowed: if you want to run the same stylesheet in more than one thread, create a single Templates object for the compiled stylesheet, and then one Transformer object for each transformation. – Michael Kay Dec 31 '14 at 10:02

2 Answers2

2

For the record, from the information given, I think it is very likely that the cause of this issue was that the JAXP Transformer object was being used to perform multiple transformations concurrently in different threads, which is not allowed.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
1

Based on the stack trace, Saxon is encountering a NullPointerException when trying to get the value for one of the global parameters used in this expression:

request:searchPattren($requestString, $segmentName, $searchBlbContent, $decodeFlag)

This expression involves two global parameters: $requestString, and $decodeFlag.

Since you only encounter this error sometimes, this suggests that you are sometimes passing in a null value for one (or both) of these parameters.

Please verify that you are never passing in null values for either of these parameters.

JLRishe
  • 99,490
  • 19
  • 131
  • 169