在wso2 EI6.1.1中使用Smooks将数据写入文件时,如何解决异常“ org.milyn.cdr.SmooksConfigurationException:”?

时间:2019-01-08 07:25:59

标签: freemarker wso2ei smooks

我正在使用

Data(xml)写到file(csv)
  

在wso2 EI 6.1.1中抽烟调解器,

获得下面提到的异常

我已创建名为'WriteDataToCSV'的代理服务和名为smooksconfiguration

SmooksCSVConfig文件

WriteDataToCSV:

<?xml version="1.0" encoding="UTF-8"?>
<proxy name="WriteDataToCSV" startOnLoad="true" transports="http https"
    xmlns="http://ws.apache.org/ns/synapse">
    <target>
        <inSequence>
            <payloadFactory media-type="xml">
                <format>
                    <order id="231">
                        <header>
                            <customer number="12345">Justin</customer>
                        </header>
                        <order-items>
                            <order-item id="1">
                                <product>Fogg</product>
                                <price>186</price>
                                <quantity>1</quantity>
                            </order-item>
                            <order-item id="2">
                                <product>Powder</product>
                                <price>50</price>
                                <quantity>1</quantity>
                            </order-item>
                        </order-items>
                    </order>
                </format>
                <args />
            </payloadFactory>
             <log level="full"/>
            <smooks config-key="SmooksCSVConfig">
                <input type="xml"/>
                <output property="textResult" type="text"/>
            </smooks>

        </inSequence>
        <outSequence />
        <faultSequence />
    </target>
</proxy>

SmokesCSVConfig:

<?xml version="1.0" encoding="UTF-8"?>
<localEntry key="SmooksCSVConfig" xmlns="http://ws.apache.org/ns/synapse">
    <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:file="http://www.milyn.org/xsd/smooks/file-routing-1.1.xsd" xmlns:ftl="http://www.milyn.org/xsd/smooks/freemarker-1.1.xsd" xmlns:jb="http://www.milyn.org/xsd/smooks/javabean-1.4.xsd">
     <core:filterSettings type="SAX" />
     <jb:bean beanId="order" class="java.util.Hashtable" createOnElement="order">
            <jb:value property="orderId" decoder="Integer" data="order/@id"/>
            <jb:value property="customerNumber" decoder="Long" data="header/customer/@number"/>
            <jb:value property="customerName" data="header/customer"/>
            <jb:wiring property="orderItem" beanIdRef="orderItem"/>
        </jb:bean>
<jb:bean beanId="orderItem" class="java.util.Hashtable" createOnElement="order-item">
            <jb:value property="itemId" decoder="Integer" data="order-item/@id"/>
            <jb:value property="productId" decoder="Long" data="order-item/product"/>
            <jb:value property="quantity" decoder="Integer" data="order-item/quantity"/>
            <jb:value property="price" decoder="Double" data="order-item/price"/>
        </jb:bean>
        <file:outputStream openOnElement="order-item" resourceName="orderItemSplitStream">
            <file:fileNamePattern>order-${order.orderId}-${order.orderItem.itemId}.xml</file:fileNamePattern>
            <file:destinationDirectoryPattern>E:/Smooks/target/orders/</file:destinationDirectoryPattern>
            <file:listFileNamePattern>order-${order.orderId}.lst</file:listFileNamePattern>
            <file:highWaterMark mark="10"/>
        </file:outputStream>
 <ftl:freemarker applyOnElement="order-item">
            <ftl:template>E:/Smooks/target/classes/CustomersTrans.ftl</ftl:template>
            <ftl:use>
                <!-- Output the templating result to the "orderItemSplitStream" file output stream... -->
                <ftl:outputTo outputStreamResource="orderItemSplitStream"/>
            </ftl:use>
        </ftl:freemarker>

    </smooks-resource-list>

CustomersTrans.ftl:

<orderitem id="${.vars["order-item"].@id}" order="${order.@id}">
    <customer>
        <name>${order.header.customer}</name>
        <number>${order.header.customer.@number}</number>
    </customer>
    <details>
        <productId>${.vars["order-item"].product}</productId>
        <quantity>${.vars["order-item"].quantity}</quantity>
        <price>${.vars["order-item"].price}</price>
    </details>
</orderitem>

有类似的异常,

org.milyn.cdr.SmooksConfigurationException: Error invoking @Initialize method 'initialize' on class 'org.milyn.templating.freemarker.FreeMarkerTemplateProcessor'.

我希望将拆分数据写入到提到的文件夹下的文件中(E:/ Smooks / target / orders) 您能帮我解决上述问题吗?

注意: Doesn't work for me

0 个答案:

没有答案
相关问题