product-ei
product-ei copied to clipboard
EI 6.6.0 cannot process XSLT 2.0 stylesheets even with Xpath 2.0 enabled
Description: I have defined simple XSLT 2.0 stylesheet in Local Entry. This was working in 6.4.0 and xpath 2.0 didn't have to be enabled. Now it does not work on fresh 6.6.0 install.
<?xml version="1.0" encoding="UTF-8"?>
<localEntry key="ASDX-COM-TestXslt20" xmlns="http://ws.apache.org/ns/synapse">
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="UTF-8" indent="yes" method="xml" version="1.0"/>
<xsl:template match="*">
<root>
<xsl:value-of select="replace('my string', 'my', 'best')"/>
</root>
</xsl:template>
</xsl:stylesheet>
</localEntry>
Xpath 2.0 is enabled and verified with sequence before xlst.
<property expression="replace('abcd', 'b', '_')" name="test" scope="default" type="STRING"/>
<log level="custom">
<property expression="$ctx:test" name="test"/>
</log>
<payloadFactory media-type="xml">
<format>
<root/>
</format>
<args/>
</payloadFactory>
<xslt key="ASDX-COM-TestXslt20"/>
Exception
TID: [-1234] [] [2020-03-30 18:39:40,331] ERROR {org.apache.synapse.mediators.transform.XSLTMediator} - Fatal error occurred in stylesheet parsing. ; Line#: 5; Column#: 76
javax.xml.transform.TransformerException: Could not find function: replace
at org.apache.xpath.compiler.XPathParser.error(XPathParser.java:610)
at org.apache.xpath.compiler.XPathParser.FunctionCall(XPathParser.java:1507)
at org.apache.xpath.compiler.XPathParser.PrimaryExpr(XPathParser.java:1446)
at org.apache.xpath.compiler.XPathParser.FilterExpr(XPathParser.java:1345)
at org.apache.xpath.compiler.XPathParser.PathExpr(XPathParser.java:1278)
at org.apache.xpath.compiler.XPathParser.UnionExpr(XPathParser.java:1236)
at org.apache.xpath.compiler.XPathParser.UnaryExpr(XPathParser.java:1142)
at org.apache.xpath.compiler.XPathParser.MultiplicativeExpr(XPathParser.java:1063)
at org.apache.xpath.compiler.XPathParser.AdditiveExpr(XPathParser.java:1005)
at org.apache.xpath.compiler.XPathParser.RelationalExpr(XPathParser.java:930)
at org.apache.xpath.compiler.XPathParser.EqualityExpr(XPathParser.java:870)
at org.apache.xpath.compiler.XPathParser.AndExpr(XPathParser.java:834)
at org.apache.xpath.compiler.XPathParser.OrExpr(XPathParser.java:807)
at org.apache.xpath.compiler.XPathParser.Expr(XPathParser.java:790)
at org.apache.xpath.compiler.XPathParser.initXPath(XPathParser.java:129)
at org.apache.xpath.XPath.<init>(XPath.java:227)
at org.apache.xalan.processor.StylesheetHandler.createXPath(StylesheetHandler.java:152)
at org.apache.xalan.processor.XSLTAttributeDef.processEXPR(XSLTAttributeDef.java:763)
at org.apache.xalan.processor.XSLTAttributeDef.processValue(XSLTAttributeDef.java:1405)
at org.apache.xalan.processor.XSLTAttributeDef.setAttrValue(XSLTAttributeDef.java:1601)
at org.apache.xalan.processor.XSLTElementProcessor.setPropertiesFromAttributes(XSLTElementProcessor.java:355)
at org.apache.xalan.processor.XSLTElementProcessor.setPropertiesFromAttributes(XSLTElementProcessor.java:267)
at org.apache.xalan.processor.ProcessorTemplateElem.startElement(ProcessorTemplateElem.java:78)
at org.apache.xalan.processor.StylesheetHandler.startElement(StylesheetHandler.java:623)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:917)
at org.apache.synapse.mediators.transform.XSLTMediator.createTemplate(XSLTMediator.java:469)
at org.apache.synapse.mediators.transform.XSLTMediator.performXSLT(XSLTMediator.java:300)
at org.apache.synapse.mediators.transform.XSLTMediator.mediate(XSLTMediator.java:258)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:109)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)
at org.apache.synapse.mediators.template.TemplateMediator.mediate(TemplateMediator.java:133)
at org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:148)
at org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:84)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:109)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.apache.synapse.rest.Resource.process(Resource.java:331)
at org.apache.synapse.rest.API.process(API.java:441)
at org.apache.synapse.rest.RESTRequestHandler.apiProcess(RESTRequestHandler.java:135)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:113)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:71)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:327)
at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:98)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:368)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:189)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Suggested Labels: 6.6.0
Affected Product Version: 6.6.0
OS, DB, other environment details and versions:
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.5+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.5+10, mixed mode)
CentOS Linux release 7.7.1908 (Core)
Hi Tomas, I tested this scenario in a similar setup and its working for me. Could you please retry after following steps.
-
Uncomment the following line in <EI_HOME>/conf/synapse.properties file synapse.xpath.dom.failover.enabled=true
-
Re-start the server
@GDLMadushanka This was of course enabled. That was the first thing I tried before posting this issue. That's why there is a property
mediator with replace
function before calling XLST. I was testing, that the synapse.xpath.dom.failover.enabled=true
is set and working correctly.
The issue isn't XPath 2.0 in sequence mediation. The issue is, that XSLT mediator uses Xalan for XSLT 2.0 (which is not supported in Xalan) even when the synapse.xpath.dom.failover.enabled=true
is enabled.
I tested it on two servers. One was installed by my colleague on CentOS 7 via RPM, where JDK 11.0.5 is present by default. The second was Ubuntu 18.04 installed via .deb package, where JDK 1.8.0-211 is present by default.
Why different install method produces different result, I don't know. Anyway I solved it by modifying startup script. I added to the integrator.sh
following parameter.
-Djavax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl \
This is a hack, since I haven't found any info about it. I would prefer official resolution, because I have no idea, if this will not make EI unstable in other areas.
I have observed the same behaviour when upgrading EI 6.5.0 -> 6.6.0:
javax.xml.transform.TransformerException: Could not find function: upper-case
at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:933)
at org.apache.synapse.mediators.transform.XSLTMediator.createTemplate(XSLTMediator.java:469)
... 29 more
Caused by: javax.xml.transform.TransformerException: org.xml.sax.SAXException: Could not find function: upper-case
javax.xml.transform.TransformerException: Could not find function: upper-case
at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:925)
... 30 more
Caused by: org.xml.sax.SAXException: Could not find function: upper-case
javax.xml.transform.TransformerException: Could not find function: upper-case
at org.apache.xalan.processor.XSLTAttributeDef.processEXPR(XSLTAttributeDef.java:769)
at org.apache.xalan.processor.XSLTAttributeDef.processValue(XSLTAttributeDef.java:1405)
at org.apache.xalan.processor.XSLTAttributeDef.setAttrValue(XSLTAttributeDef.java:1601)
at org.apache.xalan.processor.XSLTElementProcessor.setPropertiesFromAttributes(XSLTElementProcessor.java:355)
at org.apache.xalan.processor.XSLTElementProcessor.setPropertiesFromAttributes(XSLTElementProcessor.java:267)
at org.apache.xalan.processor.ProcessorTemplateElem.startElement(ProcessorTemplateElem.java:78)
at org.apache.xalan.processor.StylesheetHandler.startElement(StylesheetHandler.java:623)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:917)
... 30 more
Caused by: javax.xml.transform.TransformerException: Could not find function: upper-case
However, the following API works:
<api xmlns="http://ws.apache.org/ns/synapse" name="Test" context="/test">
<resource methods="GET" uri-template="/test">
<inSequence>
<property name="text" expression="upper-case('hello')" scope="default" type="STRING"/>
<payloadFactory media-type="json">
<format>{ "text" : "$1"}</format>
<args>
<arg evaluator="xml" expression="$ctx:text"/>
</args>
</payloadFactory>
<respond/>
</inSequence>
</resource>
</api>
* About to connect() to xxx port 8280 (#0)
* Trying 10.80.106.9...
* Connected to xxx (xxx) port 8280 (#0)
> GET /test/test HTTP/1.1
> User-Agent: curl/7.29.0
> Host: xxx:8280
> Accept: */*
>
< HTTP/1.1 200 OK
< Accept: */*
< Access-Control-Allow-Methods: GET
< Host: wso2eiq2.integration.cgmsa.co.za:8280
< Access-Control-Allow-Headers: content-type
< Content-Type: application/json; charset=UTF-8
< Date: Thu, 04 Mar 2021 10:10:17 GMT
< Transfer-Encoding: chunked
<
* Connection #0 to host xxx left intact
{ "text" : "HELLO"}
I can verify the workaround fixes the issue. Thanks so much @TomasTokaMrazek!
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
[vernono@wso2eiq2 wso2ei-6.6.0]$ java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
[vernono@wso2eiq2 wso2ei-6.6.0]$ grep failover conf/synapse.properties
synapse.xpath.dom.failover.enabled=true
[vernono@wso2eiq2 wso2ei-6.6.0]$
Hi,
- EI_HOME>/conf/synapse.properties file synapse.xpath.dom.failover.enabled=true
- -Djavax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl \
I tried the 2 methods you mentioned above, both separately and together, but it did not improve in 6.6.0. It was written in a forum that it was necessary to remove the saxon jar and try, but it did not work. Do you have any other advice?
Unfortunately I don't. Since 6.6.0 release was bad overall with severe performance issues, we jumped directly to Micro Integrator 4.0.0, now using 4.1.0 and planning to upgrade to 4.2.0.
My only advice is do the same. Micro Integrator 4.2.0 finally has Saxon 10.8 build-in, so no replacement is needed and XSLT 3.0 and possibly XPATH 3.0 is supported out of the box, only synapse.xpath.dom.failover.enabled=true
needs to be set.