title: Exchange edifact message with smooks - error during response
body: <p>I need to write osgi bundle to simple unmarshal edifact message (invoice), and persist invoice in database. I receive an exception during response</p>
  
  <p>My environment:
  - ServiceMix 5.0.0</p>
  
  <p>I have following camel route</p>
  
  <pre><code>    &lt;route&gt;
          &lt;from uri="mina2:tcp://localhost:9999?textline=true&amp;amp;encoding=utf-8" /&gt;
          &lt;to uri="smooks://smooks-config.xml" /&gt;
      &lt;/route&gt;
  
      &lt;route&gt;
          &lt;from uri="direct:invoice" /&gt;
          &lt;process ref="invoiceProcessor" /&gt;
      &lt;/route&gt; 
  </code></pre>
  
  <p>where smooks-config.xml is:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;smooks-resource-list 
      xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
      xmlns:csv="http://www.milyn.org/xsd/smooks/csv-1.2.xsd" 
      xmlns:edi="http://www.milyn.org/xsd/smooks/edi-1.2.xsd"
      xmlns:unedifact="http://www.milyn.org/xsd/smooks/unedifact-1.4.xsd"
      xmlns:core="http://www.milyn.org/xsd/smooks/smooks-core-1.4.xsd"
      xmlns:camel="http://www.milyn.org/xsd/smooks/camel-1.4.xsd"
      &gt;
  
      &lt;unedifact:reader mappingModel="urn:org.milyn.edi.unedifact:d96a-mapping:1.4" ignoreNewLines="true" /&gt;
  
      &lt;import file="/org/milyn/edi/unedifact/d96a/message-bindingconfig.xml" /&gt;
  
      &lt;camel:route beanId="INVOIC"&gt;
          &lt;camel:to endpoint="direct:invoice"/&gt;
      &lt;/camel:route&gt;
  
      &lt;core:exports&gt;
          &lt;core:result type="org.milyn.payload.StringResult"/&gt;
      &lt;/core:exports&gt;
  
  &lt;/smooks-resource-list&gt;
  </code></pre>
  
  <p>As you can see I am using standard d96a binding and mapping.</p>
  
  <p>When I call netcat to send sample edifact message, all processing is going to be fine except response. During response I receive:</p>
  
  <pre><code>Stacktrace
  ---------------------------------------------------------------------------------------------------------------------------------------
  org.milyn.SmooksException: Failed to filter source.
          at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:97)[221:org.milyn.smooks.osgi:1.5.2]
          at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:64)[221:org.milyn.smooks.osgi:1.5.2]
          at org.milyn.Smooks._filter(Smooks.java:526)[221:org.milyn.smooks.osgi:1.5.2]
          at org.milyn.Smooks.filterSource(Smooks.java:477)[221:org.milyn.smooks.osgi:1.5.2]
          at org.milyn.smooks.camel.processor.SmooksProcessor.process(SmooksProcessor.java:107)[221:org.milyn.smooks.osgi:1.5.2]
          at org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:103)[98:org.apache.camel.camel-core:2.12.3]
          at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:71)[98:org.apache.camel.camel-core:2.12.3]
          at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)[98:org.apache.camel.camel-core:2.12.3]
          at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)[98:org.apache.camel.camel-core:2.12.3]
          at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)[98:org.apache.camel.camel-core:2.12.3]
          at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)[98:org.apache.camel.camel-core:2.12.3]
          at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[98:org.apache.camel.camel-core:2.12.3]
          at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)[98:org.apache.camel.camel-core:2.12.3]
          at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[98:org.apache.camel.camel-core:2.12.3]
          at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[98:org.apache.camel.camel-core:2.12.3]
          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:105)[98:org.apache.camel.camel-core:2.12.3]
          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:87)[98:org.apache.camel.camel-core:2.12.3]
          at org.apache.camel.component.mina2.Mina2Consumer$ReceiveHandler.messageReceived(Mina2Consumer.java:339)[186:org.apache.camel.camel-mina2:2.12.3]
          at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:690)[26:org.apache.mina.core:2.0.7]
          at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:417)[26:org.apache.mina.core:2.0.7]
          at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:47)[26:org.apache.mina.core:2.0.7]
          at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:765)[26:org.apache.mina.core:2.0.7]
          at org.apache.mina.core.filterchain.IoFilterEvent.fire(IoFilterEvent.java:74)[26:org.apache.mina.core:2.0.7]
          at org.apache.mina.core.session.IoEvent.run(IoEvent.java:63)[26:org.apache.mina.core:2.0.7]
          at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTask(OrderedThreadPoolExecutor.java:769)[26:org.apache.mina.core:2.0.7]
          at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTasks(OrderedThreadPoolExecutor.java:761)[26:org.apache.mina.core:2.0.7]
          at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.run(OrderedThreadPoolExecutor.java:703)[26:org.apache.mina.core:2.0.7]
          at java.lang.Thread.run(Thread.java:744)[:1.7.0_51]
  Caused by: java.util.EmptyStackException
          at java.util.Stack.peek(Stack.java:102)[:1.7.0_51]
          at java.util.Stack.pop(Stack.java:84)[:1.7.0_51]
          at org.milyn.namespace.NamespaceDeclarationStack.popNamespaces(NamespaceDeclarationStack.java:132)[221:org.milyn.smooks.osgi:1.5.2]
          at org.milyn.edisax.unedifact.UNEdifactInterchangeParser.parse(UNEdifactInterchangeParser.java:125)[221:org.milyn.smooks.osgi:1.5.2]
          at org.milyn.smooks.edi.unedifact.UNEdifactReader.parse(UNEdifactReader.java:75)[221:org.milyn.smooks.osgi:1.5.2]
          at org.milyn.delivery.sax.SAXParser.parse(SAXParser.java:76)[221:org.milyn.smooks.osgi:1.5.2]
          at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:86)[221:org.milyn.smooks.osgi:1.5.2]
          ... 27 more
  </code></pre>