本文介绍了Camel DataFormat Jackson使用蓝图XML DSL抛出上下文异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论我将数据格式放在XML DSL蓝图中,我都会在不同的地方出现此错误。如果我删除它,它的工作原理,但我当然不能将JSON转换为POJO。 ???任何帮助或告诉我我做错了什么,我错过了什么。谢谢!

No matter where I place the dataformats in XML DSL blueprint, I get this error just starting at different places. if I remove it, it works but of course I can't convert JSON to POJO. ??? any help or tell me what I'm doing wrong, what i'm missing. thanks!

错误

Unable to start blueprint container for bundle passthrumt1.core/1.0.1.SNAPSHOT
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'endpoint'. One of '{"http://camel.apache.org/schema/blueprint":redeliveryPolicyProfile, "http://camel.apache.org/schema/blueprint":onException, "http://camel.apache.org/schema/blueprint":onCompletion, "http://camel.apache.org/schema/blueprint":intercept, "http://camel.apache.org/schema/blueprint":interceptFrom, "http://camel.apache.org/schema/blueprint":interceptSendToEndpoint, "http://camel.apache.org/schema/blueprint":restConfiguration, "http://camel.apache.org/schema/blueprint":rest, "http://camel.apache.org/schema/blueprint":route}' is expected.

XML DSL

   <camelContext
      id="com.passthru.coreCamelContext"
      trace="true"
      xmlns="http://camel.apache.org/schema/blueprint"
      allowUseOriginalMessage="false"
      streamCache="true"
      errorHandlerRef="deadLetterErrorHandler" >

    <properties>
        <property key="http.proxyHost" value="PITC-Zscaler-Americas.proxy.corporate.com"/>
        <property key="http.proxyPort" value="80"/>
    </properties>

    <streamCaching  id="CacheConfig"
                    spoolUsedHeapMemoryThreshold="70"
                    anySpoolRules="true"/>
<!--  -->
    <dataFormats>
            <json id="Json2Pojo" library="Jackson" unmarshalTypeName="com.passthru.core.entities.TokenEntities">
            </json>
    </dataFormats>

    <endpoint id="predixConsumer" uri="direct:preConsumer" />
    <endpoint id="predixProducer" uri="direct:preProducer" />
    <endpoint id="getToken" uri="direct:getToken" />

      <onException>
        <exception>com.passthru.dataservice.PDXDataServiceInvalidDataException</exception>
        <redeliveryPolicy maximumRedeliveries="3" />
        <handled>
          <constant>true</constant>
        </handled>
        <log
          message="Invalid Data From Data Service"
          loggingLevel="ERROR" />
        <setBody>
          <simple>${body.toString}</simple>
        </setBody>
        <to uri="file:{{errorArchive}}" />
      </onException>

如果我将数据格式置于属性之上,它会抱怨,我必须按顺序删除属性和streamcache语句它的工作原理。但我需要代理属性。有什么建议???再次感谢

If I place the dataformats above properties, it complains, I have to remove properties and streamcache statements in order for it to work. but I need the proxy properties. any suggestions??? thanks again

如果

<camelContext
  id="com.ge.digital.passthru.coreCamelContext"
  trace="true"
  xmlns="http://camel.apache.org/schema/blueprint"
  allowUseOriginalMessage="false"
  streamCache="true"
  errorHandlerRef="deadLetterErrorHandler" >
<dataFormats>
    <json id="Json2Pojo" library="Jackson" unmarshalTypeName="com.passthru.core.entities.TokenEntities"/>
</dataFormats>
<properties>
    <property key="http.proxyHost" value="PITC-Zscaler-Americas-Cincinnati3PR.proxy.corporate.com"/>
    <property key="http.proxyPort" value="80"/>
</properties>

我得到这个

Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'properties'. One of '{"http://camel.apache.org/schema/blueprint":redeliveryPolicyProfile, "http://camel.apache.org/schema/blueprint":onException, "http://camel.apache.org/schema/blueprint":onCompletion, "http://camel.apache.org/schema/blueprint":intercept, "http://camel.apache.org/schema/blueprint":interceptFrom, "http://camel.apache.org/schema/blueprint":interceptSendToEndpoint, "http://camel.apache.org/schema/blueprint":restConfiguration, "http://camel.apache.org/schema/blueprint":rest, "http://camel.apache.org/schema/blueprint":route}' is expected.

我错过了什么?

推荐答案

Camel蓝图XML针对。
您对名称为 camelContextFactoryBean 的复杂类型感兴趣,其中包含具有固定顺序的可用元素序列。

Camel blueprint XML is validated against camel-blueprint.xsd.You are interested in complex type with name camelContextFactoryBean which contains sequence of available elements with fixed order.

此序列中定义的camelContext元素的正确顺序为:


  • 属性

  • globalOptions

  • propertyPlaceholder

  • package

  • packageScan

  • contextScan

  • jmxAgent

  • streamCaching

  • export

  • defaultServiceCallConfiguration

  • serviceCallConfiguration

  • defaultHystrixConfiguration

  • hystrixConfiguration

  • routeBuilder

  • routeContextRef

  • restContextRef

  • threadPoolProfile

  • threadPool

  • 端点

  • dataFormats

  • 变形金刚

  • 验证者

  • redeliveryPolicyProfile

  • onException

  • onCompletion

  • 拦截

  • interceptFrom

  • interceptSendToEndpoint

  • restConfiguration

  • 休息

  • 路线

  • properties
  • globalOptions
  • propertyPlaceholder
  • package
  • packageScan
  • contextScan
  • jmxAgent
  • streamCaching
  • export
  • defaultServiceCallConfiguration
  • serviceCallConfiguration
  • defaultHystrixConfiguration
  • hystrixConfiguration
  • routeBuilder
  • routeContextRef
  • restContextRef
  • threadPoolProfile
  • threadPool
  • endpoint
  • dataFormats
  • transformers
  • validators
  • redeliveryPolicyProfile
  • onException
  • onCompletion
  • intercept
  • interceptFrom
  • interceptSendToEndpoint
  • restConfiguration
  • rest
  • route

解决问题全部移动端点声明正好在 dataFormats

To solve your problem move all endpoint declarations right above dataFormats.

这篇关于Camel DataFormat Jackson使用蓝图XML DSL抛出上下文异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 10:01