org.apache.camel.NoTypeConversionAvailableException:没有可用的类型转换器

时间:2016-10-13 19:17:51

标签: java apache-camel

我将一个java应用程序从Camel 2.13.4升级到2.17.3&我得到下面列出的例外。该应用程序在升级之前工作正常。我现在需要在Camel路线中增加一个额外的条目吗?下面列出的是代码&路由配置,我认为是相关的。

异常

Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: com.application.header.TestFileHeader to the required type: java.util.ArrayList with value com.application.header.TestFileHeader@1aac3b2c

骆驼配置

<route id="RouteDirect"> 
    <from uri="direct:RouteDirectFile" />
        <onException>
                <exception>java.lang.IllegalArgumentException</exception>
                <redeliveryPolicy maximumRedeliveries="1" />
                <handled>
                    <constant>true</constant>
                 </handled>
                <to uri="bean:TestBAImpl?method=setVMSUnknown" />  
                <to uri="log:java.lang.IllegalArgumentException" />
                <transform>
                    <simple>Failed to process record of file - ${header.CamelFileNameOnly} \n\n Reason - ${exception.message}  \n\n Position in file - ${header.CamelSplitIndex} \n\n Record - ${in.body} \n\n ${exception.stacktrace}</simple>                         
                </transform>
                <to uri="smtp://mail1.com?contentType=text/html&amp;to==a@b.com&amp;from==a@b.com&amp;subject=File Processing Status -  Error" />
        </onException> 
        <onException>
            <exception>java.text.ParseException</exception>
            <redeliveryPolicy maximumRedeliveries="1" />
            <handled>
                <constant>true</constant>
             </handled>
            <to uri="bean:TestBAImpl?method=setVMSUnknown" />  
            <to uri="log:java.text.ParseException" />
            <transform>
                    <simple>Failed to process record of file - ${header.CamelFileNameOnly} \n\n Reason - ${exception.message}  \n\n Position in file - ${header.CamelSplitIndex} \n\n Record - ${in.body} \n\n ${exception.stacktrace}</simple>                         
                </transform>
           <to uri="smtp://mail1.com?contentType=text/html&amp;to==a@b.com&amp;from==a@b.com&amp;subject=File Processing Status -  Error" />
        </onException> 
        <onException>
            <exception>java.io.FileNotFoundException</exception>
             <redeliveryPolicy maximumRedeliveries="12"  redeliveryDelay="5000" retryAttemptedLogLevel="WARN"/>
            <handled>
                <constant>true</constant>
             </handled>
            <to uri="log:java.io.FileNotFoundException"></to>
            <transform>
                    <simple>Failed to process ${header.CamelFileNameOnly} \n\n Reason - ${exception.message}  \n\n ${exception.stacktrace}</simple>                         
                </transform>
            <to uri="smtp://mail1.com?contentType=text/html&amp;to==a@b.com&amp;from==a@b.com&amp;subject=File Processing Status -  Error" />
        </onException> 
        <split parallelProcessing="false" strategyRef="exchangePropertiesAggregatorStrategy" >
            <tokenize token="\r\n"/>
            <choice>
                <when>
                    <simple>${in.body} regex '^HEADER.*'</simple>
                    <unmarshal ref="header.format"/>
                    <to uri="bean:TestBAImpl?method=setTestHeader" />  
                </when>
                <when>
                    <simple>${in.body} regex '^RECORD.*$'</simple>
                    <unmarshal ref="trailer.format"/>
                    <to uri="bean:TestBAImpl?method=setTestTrailer" />  
                </when>
                <otherwise>
                    <choice>
                        <when>
                            <simple>${file:name} regex '(final\.)*test.*.(txt)'</simple>
                            <unmarshal ref="dividend.format"/>
                            <to uri="bean:TestBAImpl?method=setTestBody" />
                        </when>
                        <otherwise>
                            <to uri="bean:TestBAImpl?method=setTestUnknown" /> 
                            <to uri="log:otherwise"></to> 
                        </otherwise>
                    </choice>               
                </otherwise>
            </choice>
        </split>

        <onCompletion>
           <to uri="log:completion" /> 
            <to uri="bean:TestBAImpl?method=sendCompletionEmail" />
           <transform>
                <simple>${property[completionEmailMessage]}</simple>
           </transform>
           <choice>
                <when>
                    <simple>${property[completionStatusMessage]} == 'Success'</simple>
                    <to uri="smtp://mail1.com?contentType=text/html&amp;to=a@b.com&amp;from==a@b.com&amp;subject=File Processing Status - Success" />
                </when>
                <otherwise>
                    <to uri="smtp://mail1.com?contentType=text/html&amp;to==a@b.com&amp;from==a@b.com&amp;subject=File Processing Status -  Error" />
                </otherwise>
            </choice>
        </onCompletion>
</route>

Java功能

public void setTestHeader
(
@Header("CamelFileNameOnly")        String                                      _CamelFileNameOnly,
@Header("CamelFileLastModified")    java.util.Date                              _CamelFileLastModified,
@Header("CamelFileLength")          String                                      _CamelFileLength,
@Header("CamelSplitComplete")       boolean                                     _CamelSplitComplete,
@Header("CamelSplitSize")           int                                         _CamelSplitSize,
@Header("CamelSplitIndex")          int                                         _CamelSplitIndex,
                                    ArrayList<HashMap<String, TestFileHeader>>  _TestFileHeaderList,
                                    Exchange                                    _Exchange
) throws Throwable
//...
}

0 个答案:

没有答案