2 Replies Latest reply on Jun 9, 2014 1:44 AM by rahul vashishth

    Fuse Smooks integration when transform NullPointerException

    Jacek Poreda Newbie

      Hello guys,

       

      I'm facing very strange problem.

       

      I created route:

       

      from(cxfBeanProxy).to(cxfBean).convertBodyTo(StreamSource.class).to(smooks://smooks-config.xml);

       

      cxf data format is set  to PAYLOAD.

       

      Smooks version 1.5.2

      Camel version: 2.10.0.redhat-60024

       

      Also what could be important i had to exclude xalan from smooks cause it was causing problems with dependency:

       

      <dependency>

          <groupId>org.milyn</groupId>

          <artifactId>milyn-smooks-all</artifactId>

          <exclusions>

              <exclusion>

                  <groupId>xerces</groupId>

                  <artifactId>xercesImpl</artifactId>

              </exclusion>

          </exclusions>

      </dependency>

       

      This is my smooks config:

       

      <?xml version="1.0"?>
      <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd" 
                            xmlns:core="http://www.milyn.org/xsd/smooks/smooks-core-1.3.xsd"
                            xmlns:ftl="http://www.milyn.org/xsd/smooks/freemarker-1.1.xsd">
      
          <!--
          Filter the message using the SAX Filter (i.e. not DOM, so no
          intermediate DOM for the "complete" message - there are "mini" DOMs
          for the NodeModels below)....
          -->
          <core:filterSettings type="SAX" defaultSerialization="false" />
      
          <!--
          Create 2 NodeModels. One high level model for the "order"
          (header etc) and then one for the "order-item" elements...
          -->
          <resource-config selector="$document">
              <resource>org.milyn.delivery.DomModelCreator</resource>
          </resource-config>
         
          <ftl:freemarker applyOnElement="$document">
              <ftl:template><!--<salesorder>test</salesorder>-->
              </ftl:template>
          </ftl:freemarker>
          </smooks-resource-list>
      
      

       

      This is my input file to transform:

       

      <ns2:getOrderInfoResponse xmlns:ns2="http://ws.complex.app.org/" xmlns:ns3="http://org.esb.app.complex">
          <ns3:ResponseGetOrderInfo>
              <orderInfo>
                  <customerInfo>
                      <name>ds</name>
                      <surname>asd</surname>
                  </customerInfo>
                  <orderId>10</orderId>
                  <orders>
                      <order>
                          <name>Item0</name>
                          <price>0</price>
                          <quantitiy>0</quantitiy>
                      </order>
                      <order>
                          <name>Item1</name>
                          <price>10</price>
                          <quantitiy>1</quantitiy>
                      </order>
                  </orders>
              </orderInfo>
              <resultCode>0</resultCode>
          </ns3:ResponseGetOrderInfo>
      </ns2:getOrderInfoResponse>
      
      

       

       

       

       

      When i try to transform output i get exception:

       

      org.apache.cxf.interceptor.Fault: Failed to filter source.

          at org.apache.camel.component.cxf.CxfConsumer$1.checkFailure(CxfConsumer.java:208)

          at org.apache.camel.component.cxf.CxfConsumer$1.setResponseBack(CxfConsumer.java:186)

          at org.apache.camel.component.cxf.CxfConsumer$1.asyncInvoke(CxfConsumer.java:108)

          at org.apache.camel.component.cxf.CxfConsumer$1.invoke(CxfConsumer.java:72)

          at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)

          at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94)

          at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)

          at org.apache.cxf.phase.PhaseInterceptorChain.resume(PhaseInterceptorChain.java:231)

          at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78)

          at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:348)

          at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:312)

          at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:72)

          at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:943)

          at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:879)

          at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)

          at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:188)

          at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)

          at org.eclipse.jetty.server.Server.handleAsync(Server.java:394)

          at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:446)

          at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:48)

          at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)

          at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44)

          at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)

          at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)

          at java.lang.Thread.run(Thread.java:722)

      Caused by: org.milyn.SmooksException: Failed to filter source.

          at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:97)

          at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:64)

          at org.milyn.Smooks._filter(Smooks.java:526)

          at org.milyn.Smooks.filterSource(Smooks.java:482)

          at org.milyn.smooks.camel.processor.SmooksProcessor.process(SmooksProcessor.java:112)

          at org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:101)

          at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:71)

          at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

          at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:122)

          at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:298)

          at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:117)

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

          at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

          at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

          at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

          at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

          at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

          at org.apache.camel.fabric.FabricTraceProcessor.process(FabricTraceProcessor.java:81)

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

          at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

          at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:334)

          at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:220)

          at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:46)

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

          at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:308)

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

          at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)

          at org.apache.camel.processor.Pipeline.access$100(Pipeline.java:43)

          at org.apache.camel.processor.Pipeline$1.done(Pipeline.java:135)

          at org.apache.camel.processor.RouteContextProcessor$1.done(RouteContextProcessor.java:56)

          at org.apache.camel.processor.RedeliveryErrorHandler$1.done(RedeliveryErrorHandler.java:346)

          at org.apache.camel.management.InstrumentationProcessor$1.done(InstrumentationProcessor.java:82)

          at org.apache.camel.impl.ProducerCache$1.done(ProducerCache.java:321)

          at org.apache.camel.processor.SendProcessor$2$1.done(SendProcessor.java:127)

          at org.apache.camel.component.cxf.CxfClientCallback.handleResponse(CxfClientCallback.java:61)

          at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:821)

          at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1694)

          at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPConduit.java:1535)

          at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:426)

          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

          at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(AutomaticWorkQueueImpl.java:351)

          ... 1 more

      Caused by: org.milyn.SmooksException: Error in 'org.milyn.templating.freemarker.FreeMarkerTemplateProcessor' while processing the visitAfter event.

          at org.milyn.delivery.sax.SAXHandler.processVisitorException(SAXHandler.java:573)

          at org.milyn.delivery.sax.SAXHandler.processVisitorException(SAXHandler.java:559)

          at org.milyn.delivery.sax.SAXHandler.visitAfter(SAXHandler.java:396)

          at org.milyn.delivery.sax.SAXHandler.endElement(SAXHandler.java:204)

          at org.milyn.delivery.SmooksContentHandler.endElement(SmooksContentHandler.java:96)

          at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:606)

          at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1742)

          at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2900)

          at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)

          at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)

          at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:489)

          at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)

          at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)

          at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)

          at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)

          at org.milyn.delivery.sax.SAXParser.parse(SAXParser.java:76)

          at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:86)

          ... 50 more

      Caused by: java.lang.NullPointerException

          at freemarker.core.TextBlock.accept(TextBlock.java:91)

          at freemarker.core.Environment.visit(Environment.java:209)

          at freemarker.core.Environment.process(Environment.java:189)

          at freemarker.template.Template.process(Template.java:237)

          at org.milyn.templating.freemarker.FreeMarkerTemplateProcessor.applyTemplate(FreeMarkerTemplateProcessor.java:358)

          at org.milyn.templating.freemarker.FreeMarkerTemplateProcessor.applyTemplate(FreeMarkerTemplateProcessor.java:351)

          at org.milyn.templating.freemarker.FreeMarkerTemplateProcessor.visitAfter(FreeMarkerTemplateProcessor.java:329)

          at org.milyn.delivery.sax.SAXHandler.visitAfter(SAXHandler.java:389)

          ... 64 more