2 Replies Latest reply on May 28, 2009 6:21 PM by noelo

    Smooks not finding bean in ESB message

    noelo

      Hi,
      I'm having a problem with a really, really simple test ESB project that I cannot seem to solve.

      I have an ESB service which all it does is receive an XML body sent via EBWS, parse it and populate a hash map and them populate another XML document using the contents of the hash map. This is the service:

       <service category="Performance" description="Web service to evaluate performance of the ESB" invmScope="GLOBAL"
       name="PerformanceTest">
       <actions mep="RequestResponse" inXsd="/MsgPerformanceRequest.xsd" outXsd="/MsgPerformanceResponse.xsd"
       validate="false" webservice="true">
       <action class="org.jboss.soa.esb.actions.SystemPrintln" name="InMessageAct">
       <property name="message" value="InMessage->>" />
       <property name="printfull" value="true" />
       </action>
       <action class="org.jboss.soa.esb.smooks.SmooksAction" name="request-response_transformer1">
       <property name="smooksConfig" value="/SmooksTransformIn.xml" />
       <property name="resultType" value="JAVA" />
       <property name="reportPath" value="/tmp/report-in.html" />
       </action>
       <action class="org.jboss.soa.esb.actions.SystemPrintln" name="InterMessageAct">
       <property name="message" value="Intermediate->>" />
       <property name="printfull" value="true" />
       </action>
       <action class="org.jboss.soa.esb.smooks.SmooksAction" name="request-response_transformer2">
       <property name="smooksConfig" value="/SmooksTransformOut.xml" />
       <property name="resultType" value="STRING" />
       <property name="reportPath" value="/tmp/report-out.html" />
       </action>
       <action class="org.jboss.soa.esb.actions.SystemPrintln" name="OutMessageAct">
       <property name="message" value="OutMessag->>" />
       <property name="printfull" value="true" />
       </action>
       </actions>


      The first smooks call works and a hash map is created. I can see this in the message body
      context: {}
      body: [ objects: {org.jboss.soa.esb.message.defaultEntry-set-stack=java.lang.Exception: setPayload stack trace for 'org.jboss.soa.esb.message.defaultEntry'., org.jboss.soa
      .esb.message.defaultEntry={PerfBean={DEmsgID=1, DEpayload=3453465687698, DEpayloadSize=23}}, SmooksExecutionContext={}} ]
      fault: [ ]
      

      The problem is with the second smooks xform when it tries to populate a freemarker template with the PerfBean bean. I see the following in the log file

      2009-05-28 21:24:49,279 ERROR [freemarker.runtime]
      Expression PerfBean is undefined on line 5, column 28 in PerformanceResponse.ftl.
      The problematic instruction:
      ----------
      ==> ${PerfBean.DEpayloadSize} [on line 5, column 26 in PerformanceResponse.ftl]
      ----------
      
      Java backtrace for programmers:
      ----------
      freemarker.core.InvalidReferenceException: Expression PerfBean is undefined on line 5, column 28 in PerformanceResponse.ftl.
       at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
       at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:134)
       at freemarker.core.Dot._getAsTemplateModel(Dot.java:78)


      This is the template:
      <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
       <env:Header/>
       <env:Body>
       <perf:Message xmlns:perf="http://perfws.test.com/ws/performance">
       <MsgPayloadSize>${PerfBean.DEpayloadSize}</MsgPayloadSize>
       <MsgPayload>${PerfBean.DEpayloadSize}</MsgPayload>
       </perf:Message>
       </env:Body>
      </env:Envelope>
      


      and this is the smooks config
      <?xml version="1.0"?>
      <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd">
       <resource-config selector="global-parameters">
       <param name="stream.filter.type">SAX</param>
       </resource-config>
       <resource-config selector="$document">
       <resource>PerformanceResponse.ftl</resource>
       <param name="action">replace</param>
       </resource-config>
      </smooks-resource-list>
      



      I've traced through the ESB and Smooks code and I can see the PerfBean being passed in but I lose track of it along the way.

      I'm sure its a small tweak to be made to the project but I can't figure it out after a number of house of trying.
      Anybody got any ideas ?

      thanks for your help
      Noel