Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-10225

Camel-Saxon is not thread safe

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.16.3, 2.17.0, 2.17.1, 2.17.2
    • 2.20.0
    • camel-saxon
    • None
    • Java 1.8.0_66-b17 Ubuntu 15.10 and Windows 10

    • Unknown

    Description

      We perform an XSLT transform within a Split. We added camel-saxon so that we could use XSLT 2 for one particular transformation. This works fine when run synchronously but when we switch parallel to true on the split we get the following errors:-

      2016-08-07T16:09:02,142 Camel (camel-1) thread #4 - Split ERROR org.apache.camel.processor.DefaultErrorHandler | | | |
      Failed delivery for (MessageId: ID-dave-ThinkPad-Edge-E540-35771-1470582541027-0-27 on ExchangeId: ID-dave-ThinkPad-Edge-E540-35771-1470582541027-0-32). Exhausted after delivery attempt: 1 caught: org.apache.camel.TypeConversionException: Error during type conversion from type: java.lang.String to the required type: java.lang.String with value <OrderResponseItem xmlns="http://api.channeladvisor.com/webservices/" xmlns:q3="http://api.channeladvisor.com/datacontracts/orders" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="q3:OrderResponseDetailComplete">
      <q3:NumberOfMatches>3</q3:NumberOfMatches>
      <q3:OrderTimeGMT>2016-07-04T08:07:38.893</q3:OrderTimeGMT>
      <q3:LastUpdateDate>2016-07-04T08:07:40.217</q3:LastUpdateDate>
      <q3:TotalOrderAmount>357.0000</q3:TotalOrderAmount>
      <q3:OrderState>Active</q3:OrderState>
      <q3:DateCancelledGMT xsi:nil="true"/>
      <q3:OrderID>9564205</q3:OrderID>
      <q3:ClientOrderIdentifier>1000008</q3:ClientOrderIdentifier>
      <q3:SellerOrderID/>
      <q3:OrderStatus>
      <q3:CheckoutStatus>Completed</q3:CheckoutStatus>
      <q3:CheckoutDateGMT>2016-07-04T08:07:38.893</q3:CheckoutDateGMT>
      <q3:PaymentSt... [Body clipped after 1000 chars, total length is 14996] due java.lang.NullPointerException. Processed by failure processor: FatalFallbackErrorHandler[Channel[Log(route2)[Error processing route: ${exception.stacktrace}]]]

      Message History
      ---------------------------------------------------------------------------------------------------------------------------------------
      RouteId ProcessorId Processor Elapsed (ms)
      [route1 ] [route1 ] [direct://in ] [ 378]
      [route1 ] [to1 ] [direct:transformOrderResponseItemToConsignmentRoute ] [ 12]
      [route2 ] [log5 ] [log ] [ 11]
      [ ] [GeneralExceptionLo] [log ] [ 3]

      Stacktrace
      ---------------------------------------------------------------------------------------------------------------------------------------
      org.apache.camel.TypeConversionException: Error during type conversion from type: java.lang.String to the required type: java.lang.String with value <OrderResponseItem xmlns="http://api.channeladvisor.com/webservices/" xmlns:q3="http://api.channeladvisor.com/datacontracts/orders" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="q3:OrderResponseDetailComplete">
      <q3:NumberOfMatches>3</q3:NumberOfMatches>
      <q3:OrderTimeGMT>2016-07-04T08:07:38.893</q3:OrderTimeGMT>
      <q3:LastUpdateDate>2016-07-04T08:07:40.217</q3:LastUpdateDate>
      <q3:TotalOrderAmount>357.0000</q3:TotalOrderAmount>
      <q3:OrderState>Active</q3:OrderState>
      <q3:DateCancelledGMT xsi:nil="true"/>
      <q3:OrderID>9564205</q3:OrderID>
      <q3:ClientOrderIdentifier>1000008</q3:ClientOrderIdentifier>
      <q3:SellerOrderID/>
      <q3:OrderStatus>
      <q3:CheckoutStatus>Completed</q3:CheckoutStatus>
      <q3:CheckoutDateGMT>2016-07-04T08:07:38.893</q3:CheckoutDateGMT>
      <q3:PaymentSt... [Body clipped after 1000 chars, total length is 14996] due java.lang.NullPointerException
      at org.apache.camel.impl.converter.BaseTypeConverterRegistry.createTypeConversionException(BaseTypeConverterRegistry.java:629) ~[camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:150) ~[camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:41) ~[camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.builder.ExpressionBuilder$64.evaluate(ExpressionBuilder.java:1533) ~[camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:36) ~[camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.processor.LogProcessor.process(LogProcessor.java:53) ~[camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:468) [camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190) [camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.processor.Pipeline.process(Pipeline.java:121) [camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.processor.Pipeline.process(Pipeline.java:83) [camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190) [camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62) [camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145) [camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:468) [camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190) [camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.processor.Pipeline.process(Pipeline.java:121) [camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.processor.Pipeline.process(Pipeline.java:83) [camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:468) [camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190) [camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109) [camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.processor.MulticastProcessor.doProcessParallel(MulticastProcessor.java:827) [camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.processor.MulticastProcessor.access$200(MulticastProcessor.java:85) [camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.processor.MulticastProcessor$1.call(MulticastProcessor.java:320) [camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.processor.MulticastProcessor$1.call(MulticastProcessor.java:305) [camel-core-2.17.2.jar:2.17.2]
      at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_66]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_66]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_66]
      at java.lang.Thread.run(Thread.java:745) [?:1.8.0_66]
      Caused by: org.apache.camel.RuntimeCamelException: java.lang.NullPointerException
      at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1690) ~[camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1285) ~[camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.impl.converter.InstanceMethodTypeConverter.convertTo(InstanceMethodTypeConverter.java:78) ~[camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:306) ~[camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:133) ~[camel-core-2.17.2.jar:2.17.2]
      ... 26 more
      Caused by: java.lang.NullPointerException
      at org.xml.sax.helpers.NamespaceSupport$Context.declarePrefix(NamespaceSupport.java:628) ~[?:1.8.0_66]
      at org.xml.sax.helpers.NamespaceSupport.declarePrefix(NamespaceSupport.java:319) ~[?:1.8.0_66]
      at net.sf.saxon.dom.DOMSender.gatherNamespaces(DOMSender.java:304) ~[Saxon-HE-9.5.1-5.jar:?]
      at net.sf.saxon.dom.DOMSender.sendElement(DOMSender.java:125) ~[Saxon-HE-9.5.1-5.jar:?]
      at net.sf.saxon.dom.DOMSender.send(DOMSender.java:93) ~[Saxon-HE-9.5.1-5.jar:?]
      at net.sf.saxon.dom.DOMObjectModel.sendSource(DOMObjectModel.java:242) ~[Saxon-HE-9.5.1-5.jar:?]
      at net.sf.saxon.event.Sender.send(Sender.java:219) ~[Saxon-HE-9.5.1-5.jar:?]
      at net.sf.saxon.IdentityTransformer.transform(IdentityTransformer.java:46) ~[Saxon-HE-9.5.1-5.jar:?]
      at org.apache.camel.converter.jaxp.XmlConverter.toResult(XmlConverter.java:132) ~[camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.converter.jaxp.XmlConverter.toResult(XmlConverter.java:116) ~[camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.converter.jaxp.XmlConverter.toString(XmlConverter.java:238) ~[camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.converter.jaxp.XmlConverter.toString(XmlConverter.java:282) ~[camel-core-2.17.2.jar:2.17.2]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_66]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_66]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_66]
      at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_66]
      at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1281) ~[camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.impl.converter.InstanceMethodTypeConverter.convertTo(InstanceMethodTypeConverter.java:78) ~[camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:306) ~[camel-core-2.17.2.jar:2.17.2]
      at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:133) ~[camel-core-2.17.2.jar:2.17.2]
      ... 26 more

      I created a test project (which I will try to attach) with a simple unit test. I found that if I remove camel-saxon then parallel appears to run fine (The unit test is not multithreaded but I can reach 20 runs without a problem). If I include camel-saxon the I start getting the problem above (usually within 8 runs of the unit test)

      I noticed that camel-saxon uses an old version of Saxon (Saxon-HE-9.5.1-5) so I overrode this with the latest version (9.7.0-7) but I still get the problem.

      I have tried against camel-saxon 2.17.2,2.17.1,2.17.0 and 2.16.3 (which required further Saxon fiddling).

      I originally raised this problem on the mailing list here: http://camel.465427.n5.nabble.com/Camel-XSLT-Saxon-not-thread-safe-tc5785086.html

      Attachments

        1. camel-split-parrallel-xslt-bug.zip
          30 kB
          David Bennison

        Activity

          People

            davsclaus Claus Ibsen
            dave_bennison David Bennison
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: