camel-quarkus
camel-quarkus copied to clipboard
Camel quarkus xslt processor runtime uriresolver not able to dynamically load resource from classpath
We were trying to use toD(xslt:${exchange property.somefileinclasspath}) , at this particular line it's resolving to RuntimeURiResolver and inside that when it tries to execute the method gettransletClassNameit throws error saying not able to find the xslt in class path.
I read the documentation as well which says camel quarkus xslt component supports only classpath, where file and http is not supported.
But classpath/somefile.xsl along with quarkus.camel.xslt.source=somefile.xslt it's still not able to resolve and giving the same issue of not able to resolve the xslt file which we provide dynamically.
Any specific reason for avoiding the runtimeresolver from dynamically loading a xsl file from classpath which is working fine with camel-xslt component.
In BuildTimerUriReaolver.java xslt I see there is support for looking up file within classpath. Also as per the pull request #437 we see only examples for static/build time loading of xslt files and we couldn't find any example of loading dynamic files by RuntimeURiResolver.
@zbendhiba. Any input/directions on this will help us a lot. Thanks in advance.
@alagusundarams I think this could be fixed in https://github.com/apache/camel-quarkus/pull/4018. And you needs to use quarkus.camel.xslt.sources=somefile.xslt for generating the translet classes at build time right now.
Any specific reason for avoiding the runtimeresolver from dynamically loading a xsl file from classpath?
I think this will generat classes at runtime and only works in JVM mode. Anyway, with the fix of https://github.com/apache/camel-quarkus/issues/3904 we can support this in JVM mode.
@zhfeng even after using the quarkus.camel.xslt.source with a set of xslt files comma separated and trying to pass the file names dynamically into toD(xslt:${exchange property.one of the filename passed in xslt.source }) we see it fails to load the xslt for transformation. I can share the sample project with exception as needed.
Note: we are also using jvm and not trying with native build.
yeah, a handy re-producer project would be very helpful. Thanks!
@alagusundarams https://github.com/apache/camel-quarkus/pull/4018 has been merged. Can you check with the lastest camel-qurakus building?
Yeah same I'm getting:
javax.xml.transform.TransformerException: unknown protocol: classpath
at org.apache.xalan.xsltc.trax.TransformerFactoryImpl.passErrorsToListener (TransformerFactoryImpl.java:661)
at org.apache.xalan.xsltc.trax.TransformerFactoryImpl.newTemplates (TransformerFactoryImpl.java:836)
at org.apache.camel.quarkus.support.xalan.XalanTransformerFactory.newTemplates (XalanTransformerFactory.java:70)
at org.apache.camel.quarkus.component.xslt.deployment.XsltProcessor.xsltResources (XsltProcessor.java:116)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at io.quarkus.deployment.ExtensionLoader$3.execute (ExtensionLoader.java:925)
at io.quarkus.builder.BuildContext.run (BuildContext.java:277)
at org.jboss.threads.ContextHandler$1.runWith (ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.run (EnhancedQueueExecutor.java:2449)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run (EnhancedQueueExecutor.java:1478)
at java.lang.Thread.run (Thread.java:834)
at org.jboss.threads.JBossThread.run (JBossThread.java:501)
[ERROR] Could not compile stylesheet
javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
at org.apache.xalan.xsltc.trax.TransformerFactoryImpl.newTemplates (TransformerFactoryImpl.java:832)
at org.apache.camel.quarkus.support.xalan.XalanTransformerFactory.newTemplates (XalanTransformerFactory.java:70)
at org.apache.camel.quarkus.component.xslt.deployment.XsltProcessor.xsltResources (XsltProcessor.java:116)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at io.quarkus.deployment.ExtensionLoader$3.execute (ExtensionLoader.java:925)
at io.quarkus.builder.BuildContext.run (BuildContext.java:277)
at org.jboss.threads.ContextHandler$1.runWith (ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.run (EnhancedQueueExecutor.java:2449)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run (EnhancedQueueExecutor.java:1478)
at java.lang.Thread.run (Thread.java:834)
at org.jboss.threads.JBossThread.run (JBossThread.java:501)```
as suggested by @zhfeng, testing with #4018 seems to resolve this issue for me (load stylesheet from classpath)... hopefully for @alagusundarams too ... Thanks !
@alagusundarams I just close this issue since the fix has been included in 2.14.0 release. Free feel to reopen it if you have any problem.