-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't use XSLT feature in native mode #501
Comments
Hi @Ballsigno Did you include the test.xsl resource in your native image? |
@shumonsharif <profile>
~ omit ~
<properties>
<skipITs>false</skipITs>
<quarkus.package.type>native</quarkus.package.type>
<quarkus.native.additional-build-args>-H:IncludeResources=test.xsl</quarkus.native.additional-build-args>
</properties> Additionally, I have tried this in native mode, and I successfully got the input stream.
|
Likely a bug; thanks for opening the issue! Would you be able to provide a small reproducer? |
Alright, I created the small one. I really want to know whether this can be fixed in a few days or not. https://github.com/Ballsigno/quarkus-cxf-xslt-test/tree/master/quarkus-cxf-xslt-test |
Thank you so much @Ballsigno ! This helps tremendously. Unfortunately, debugging native issues always takes quite a bit of time. Not sure at this stage if this will be a quick thing or not, though I'm doubtful it'll be fixed and released in a few days. Will certainly prioritize this issue for you, and will keep you posted on progress. |
@shumonsharif |
Making XSLT work in native mode is indeed tricky. Camel Quarkus supports it via its
|
Thanks for clear steps instructions🙇🏻♂️ |
To make Java code work in native mode, you need to provide some (sometimes a lot of) GraalVM configuration. That's what Quarkus extensions do (among other things). camel-quarkus-xslt does it for XSLT quite generally, although its main aim is to support Camel integration pipelines using XSLT. |
Thank you for your explanation. Indeed it seems it affects XSLT feature because the error message is changed. (But my xsl file is valid format.)
(add) The real problem is ↓
|
Hmm. I'm totally stuck on this. Apache Camel seems create a factory and compile a xsl file in initialization process, and XsltBuilder retains the result(template). On the other hand, CXF does similar things after starting application.(When I create XSLTInInterceptor.) I don't know why it doesn't work though. Is there any other way to fix this? I would really appreciate any information. |
Finally, I found a workaround! Thank you @ppalaga, I wouldn't have found this approach by myself. Instated of doing this... // AbstractXSLTInterceptor.java
try {
InputStream xsltStream = ClassLoaderUtils.getResourceAsStream(xsltPath, this.getClass());
if (xsltStream == null) {
throw new IllegalArgumentException("Cannot load XSLT from path: " + xsltPath);
}
Document doc = StaxUtils.read(xsltStream);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
try {
transformerFactory.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true);
} catch (javax.xml.transform.TransformerConfigurationException ex) {
//
}
xsltTemplate = transformerFactory.newTemplates(new DOMSource(doc)); // Somehow failed!!
} catch (TransformerConfigurationException | XMLStreamException e) {
throw new IllegalArgumentException(
String.format("Cannot create XSLT template from path: %s", xsltPath), e);
} ↓ // Inject and pass component as argument from caller.
@Inject
XsltComponent xslt;
// CustomInterceptor
try (XsltEndpoint endPoint = (XsltEndpoint) xslt.createEndpoint("xslt://" + xsltPath)) {
endPoint.init();
xsltTemplate = endPoint.getXslt().getTemplate();
} catch (Exception e) {
throw new IllegalArgumentException(
String.format("Cannot create XSLT template from path: %s", xsltPath), e);
} @shumonsharif |
I'd vote for keeping this issue open, as it still does not work flawlessly. This issue also contains a lot of useful information (thanks, @Ballsigno !). I think our general aim should be to have a general purpose Quarkus XSLT extension that could be leveraged for both Camel and CXF use cases. I need to speak with Quarkus team whether they'd be ready to host it within quarkusio/quarkus repo. |
According error it mean that we need a ReflectiveClassBuildItem for class org.apache.xalan.xsltc.compiler.ObjectFactory |
Basic Info
Hi. I have a question about XSLT feature.
↑ It works fine in dev mode, but when I tried in native mode, it was failed.
If the xsl file doesn't exist, I'm sure I will get 'Cannot load XSLT from path:" error.
Therefore I passed the right argument but failed.
Is this a bug or am I missing something?
The text was updated successfully, but these errors were encountered: