Vladimir Hambalek
Vladimir Hambalek

Reputation: 133

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

Upvotes: 13

Views: 14195

Answers (5)

Dapper Dan
Dapper Dan

Reputation: 1062

Thanks to @Ingo Wilkening for providing a solution that worked effectively for me. If your application is running on the Tomcat web server,

Locate the catalina.sh script in your Tomcat installation directory. You can use the find command as follows:

find /path/to/tomcat -name catalina.sh

Once you have found the catalina.sh file, open it in a text editor. You can use the vi editor,

vi /path/to/tomcat/bin/catalina.sh

Within the catalina.sh file, look for the section where Java options (JAVA_OPTS) are typically set. Add the following lines to set the desired Java system properties:

JAVA_OPTS="$JAVA_OPTS -Djdk.xml.xpathExprGrpLimit=0 -Djdk.xml.xpathExprOpLimit=0 -Djdk.xml.xpathTotalOpLimit=0"

Save the changes and restart tomcat.

Upvotes: 0

Leon Dong
Leon Dong

Reputation: 21

I encounter this error in my M1 mbp with Oracle OpenJDK17. It also occurs when running in product env that is based on OpenJDK17 and centos.

This answer surely helps me. But I can not modify all JVM configurations in our product cluster.

So I just set these three parameters using Java code:

System.setProperty("jdk.xml.xpathExprGrpLimit", "0");
System.setProperty("jdk.xml.xpathExprOpLimit", "0");
System.setProperty("jdk.xml.xpathTotalOpLimit", "0");

Notice: Set these parameters before TransformerFactory initialization.

Upvotes: 1

Rahul Meena
Rahul Meena

Reputation: 1

Rahul Meena -Djdk.xml.xpathExprGrpLimit=0 -Djdk.xml.xpathExprOpLimit=0 -Djdk.xml.xpathTotalOpLimit=0

Put 3 steps in your restart files.

Upvotes: 0

Sam B
Sam B

Reputation: 1

If you are running into this problem on MacBook M1 or newer. Try a compatible jdk version from either amazon corretto or zulu. I had to try multiple versions for it to work but specifically 8.275. https://www.azul.com/downloads/?version=java-8-lts&os=macos&architecture=arm-64-bit&package=jdk&show-old-builds=true

Hope this helps!

Upvotes: 0

Ingo Wilkening
Ingo Wilkening

Reputation: 136

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!

Upvotes: 12

Related Questions