It was time for me to switch from the workaround to using the "official" 
distribution of the component.  I upgraded to ServiceMix 5.5.0 and picked up 
the revised Schematron component.  The code that picks up initialization from 
ServiceMix works perfectly.  However, I am still having trouble getting the 
component to use Saxon in SMX.  I use Saxon with some XPath and XSLT code in 
routes so I know its working.  Those components have code that permits easily 
specifying Saxon just for the execution that needs it.

I have been experimenting with suggestions from the Web how to get Camel 
components to use Saxon but everything I have found is pretty all-or-nothing 
for an whole JVM or a Camel context.  But there is a lot I don't know. :-)

Looking at the master branch for SchematronEndpoint.java I see in lines 122-124 
the following code:

protected void doStart() throws Exception {
    super.doStart();

    if (transformerFactory == null) {
        createTransformerFactory();
    }

    if (rules == null) {
        try {
    . . .

As far as I can tell a non-Saxon transformer factory always exists when I get 
to this point.  I am trying to figure out how to get Saxon set just for the 
Schematron component.  Options on Camel components like XPath and XSLT make 
this easy.  For now, I modified the source code to remove the "if" and execute 
createTransformerFactory() every time to prove I could get Saxon and it works.

But it would be nice to be more elegant.  Any ideas?

--
Dan Davis

On 06/02/2015 05:50 AM, Ayache Khettar wrote:

Hi Dan

I have written a simple schematron service which can be deployed into
karaf: https://github.com/akhettar/zotix/tree/master/schematron-service.
Hope this will help.

Ayache

On 1 June 2015 at 21:58, Davis, Daniel <davi...@si.edu><mailto:davi...@si.edu> 
wrote:



Thanks.  I am grabbing a copy to build.

--
Dan

On 06/01/2015 03:37 PM, Ayache Khettar wrote:


Hi Daniel

I have checked a fix and here is the lira ticket (keep an eye on it):
https://issues.apache.org/jira/browse/CAMEL-8796 Hopefully, the changes
will make it to 2.14.1 version soon.

The above ticket only deals with class loader issue and it should get you
pass the issue you were facing on karaf.

Regards,

Ayache
On 20 May 2015 at 20:53, Davis, Daniel <davi...@si.edu><mailto:davi...@si.edu> 
wrote:



Thank you so much for both the workaround and the additional features!

--
Dan Davis

On 05/19/2015 03:49 AM, Ayache Khettar wrote:


Hi Dan

Apologies for the late reply. Only yesterday I had a bit of time to


look


into this in more details. I am able to reproduce it on the latest
serviceMix distribution. Looks like, when Camel schematron component is
deployed into SMX. it uses Xalan by default as opposed to Saxon. There


is a


way of forcing saxon implementation but it should be done properly. A


quick


solution is to fork the camel-scheamtron 2.14.1 version and set the


line


numbering to false (






https://github.com/apache/camel/blob/master/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/processor/TemplatesFactory.java


(line 68). That will solve your problem I believe.

In the mean time, I will raise a Jira ticket for this issue to do


following:


1- Expose line numbering support through uri parameter (false by


default).


2- Allow users to choose whether to use Saxon as the
transformerFactoryClass.

Hopefully, I should check in the changes by the end of this weekend.

Regards,

Ayache





On 13 May 2015 at 19:25, Davis, Daniel <davi...@si.edu><mailto:davi...@si.edu> 
wrote:



I tried with this Java DSL route.  My code is showing a dependency on
Saxon in ServiceMIx but I gather the camel-schematron component is


doing


its own binding to Xalan.  So it results in the same exception when
trying to start the route.

http://pastie.org/10187203  (Java and POM)

--
Dan Davis

On 05/13/2015 11:28 AM, Davis, Daniel wrote:


I have included the XML DSL version.  I am working up a better Java


DSL


version.  I can provoke the issue in a default ServiceMix 5.4.0


install


with only the camel-schematron feature added.  I have tried it with


the


Apache Saxon-He bundle installed too.  In the ServiceMix log, the


route


fails to start with an exception that points to ServiceMix finding


Xalan


and never finding Saxon (snippet below).  The Schematron rules run
correctly in Oxygen.  My running theory is that the camel-schematron
component version needs Saxon for the linenumbering feature but does


not


have it set as a required import, but I am still learning about the
camel-schematron component.  I am trying to get it working in the


Java


DSL by resolving the Saxon dependencies in that code but that is not
done yet.

Thank you for looking at this.

--
Dan Davis

http://pastie.org/10186857   (Contains test XML DSL route,


Schematron


rules, and test xml file)

Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
resolve endpoint:






schematron:///opt/sidora/servicemix/Input/schemas/DeploymentManifest2014.sch


due to: Not supported: http://saxon.sf.net/feature/linenumbering
        at






org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:547)[116:org.apache.camel.camel-core:2.14.1]


        at






org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:72)[116:org.apache.camel.camel-core:2.14.1]


        at






org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:202)[116:org.apache.camel.camel-core:2.14.1]


        at






org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:107)[116:org.apache.camel.camel-core:2.14.1]


        at






org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:113)[116:org.apache.camel.camel-core:2.14.1]


        at






org.apache.camel.model.SendDefinition.resolveEndpoint(SendDefinition.java:61)[116:org.apache.camel.camel-core:2.14.1]


        at






org.apache.camel.model.SendDefinition.createProcessor(SendDefinition.java:55)[116:org.apache.camel.camel-core:2.14.1]


        at






org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:500)[116:org.apache.camel.camel-core:2.14.1]


        at






org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:213)[116:org.apache.camel.camel-core:2.14.1]


        at






org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:942)[116:org.apache.camel.camel-core:2.14.1]


        ... 38 more
Caused by: java.lang.IllegalArgumentException: Not supported:
http://saxon.sf.net/feature/linenumbering
        at






org.apache.xalan.processor.TransformerFactoryImpl.setAttribute(TransformerFactoryImpl.java:571)[:]


        at






org.apache.camel.component.schematron.processor.TemplatesFactory.newTemplates(TemplatesFactory.java:68)[260:org.apache.camel.camel-schematron:2.14.1]


        at






org.apache.camel.component.schematron.SchematronEndpoint.doStart(SchematronEndpoint.java:103)[260:org.apache.camel.camel-schematron:2.14.1]


        at






org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)[116:org.apache.camel.camel-core:2.14.1]


        at






org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:2148)[116:org.apache.camel.camel-core:2.14.1]


        at






org.apache.camel.impl.DefaultCamelContext.doAddService(DefaultCamelContext.java:1032)[116:org.apache.camel.camel-core:2.14.1]


        at






org.apache.camel.impl.DefaultCamelContext.addService(DefaultCamelContext.java:993)[116:org.apache.camel.camel-core:2.14.1]


        at






org.apache.camel.impl.DefaultCamelContext.addService(DefaultCamelContext.java:989)[116:org.apache.camel.camel-core:2.14.1]


        at






org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:543)[116:org.apache.camel.camel-core:2.14.1]


        ... 47 more

--
Dan Davis

On 05/13/2015 07:21 AM, Ayache Khettar wrote:


Hi Daniel

I will try to get a working example deployed into SMX this evening


and


see


if I can reproduce the error. Could you include the source code of


your


working example so I could have a look?

Regards,

Ayache
On 12 May 2015 at 23:49, Davis, Daniel <davi...@si.edu><mailto:davi...@si.edu> 
wrote:



An update.  I got rid of camel-saxon and the Saxon bundles.  Then
created a Java DSL route packaged with Saxon-HE-9.6.0-5.jar.  Same


error


message.

In smx, it looks like camel-schematron is looking for parsers from


the


OSGI framework like - javax.xml.parsers,version=0.0.0
from org.apache.felix.framework (0)

I presume if it find Xalan first this is going to be a problem.


Onward


and upward.

--
Dan

On 05/12/2015 04:49 PM, Davis, Daniel wrote:


<dependency>


+            <groupId>net.sf.saxon</groupId>
+            <artifactId>Saxon-HE</artifactId>
+            <version>${saxon-version}</version>
+        </dependency>













Reply via email to