Search code examples
javaxmlxslt

limit set by 'FEATURE_SECURE_PROCESSING'


I used my own xlst transformator in java (XSLTTransformator) but transformation is very big and I have got error:

Caused by: javax.xml.transform.TransformerConfigurationException: JAXP0801002: the compiler encountered an XPath expression containing '107' operators that exceeds the '100' limit set by 'FEATURE_SECURE_PROCESSING'.
                at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:990)
                at com.aspp.dms.ruleengine.transformation.TemplatesCache.retrieveUncached(TemplatesCache.java:44)
                at com.aspp.dms.ruleengine.transformation.TemplatesCache.retrieveUncached(TemplatesCache.java:21)
                at com.gratex.java.util.SoftValueCache.get(SoftValueCache.java:41)
                at com.aspp.dms.ruleengine.transformation.XSLTTransformator.transform(XSLTTransformator.java:73)

Can you please help me find correct argument for java to solve my problem? Something like -DxpathOperatorsLimit=150

thank you


Solution

  • That behaviour seems to come from new FEATURE_SECURE_PROCESSING, which Oracle introduced in a recent "update" of their Java. See: https://www.oracle.com/java/technologies/javase/11-0-15-relnotes.html

    It is 3 parameters they introduced:

    1. jdk.xml.xpathExprGrpLimit Description: Limits the number of groups an XPath expression can contain. Default 10.
    2. jdk.xml.xpathExprOpLimit Description: Limits the number of operators an XPath expression can contain. Default 100.
    3. jdk.xml.xpathTotalOpLimit Description: Limits the total number of XPath operators in an XSL Stylesheet. Default 10000.

    Your problem is on #2 (JAXP0801002, default 100). We got a very similar issue on #3 (JAXP0801003, default 10.000), with this message (quoted, so google will find it):

    ERROR:  'JAXP0801003: the compiler encountered XPath expressions with an accumulated '10.002' operators that exceeds the '10.000' limit set by 'FEATURE_SECURE_PROCESSING'.'
    FATAL ERROR:  'JAXP0801003: the compiler encountered XPath expressions with an accumulated '10.002' operators that exceeds the '10.000' limit set by 'FEATURE_SECURE_PROCESSING'.'
    

    We wasted 2 days in getting away of that sh*t.

    We added some parameters to the java call:

        java -Djdk.xml.xpathExprGrpLimit=0 -Djdk.xml.xpathExprOpLimit=0 -Djdk.xml.xpathTotalOpLimit=0 -Xmx2g -Xms512m -XX:-UseGCOverheadLimit ....
    
    

    Parameters 1,2,3 to to solve the issue. Values "0" set the limits to "off". As XPath can now get huge, it might be advisable to set the heap and stack size and change behaviour of the garbage collection (parameters 4-6).

    I hope it will help you too. Have fun!