Nitesh Gupta
Nitesh Gupta

Reputation: 215

NullPointerException in Saxon while parsing XSL

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.

Upvotes: 1

Views: 2272

Answers (2)

Michael Kay
Michael Kay

Reputation: 163587

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.

Upvotes: 2

JLRishe
JLRishe

Reputation: 101748

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.

Upvotes: 1

Related Questions