【问题标题】:XML not picking up <camelContext> tagXML 没有拾取 <camelContext> 标记
【发布时间】:2012-12-31 03:04:48
【问题描述】:

这可能是一个简单的错误配置问题,但我的 xml 文档获取我的标签时遇到问题。我收到错误

"在这一行找到多个注释: - cvc-complex-type.2.4.c:匹配通配符是严格的,但找不到元素“camelContext”的声明。 - 找不到架构命名空间“http://activemq.apache.org/camel/”的元素“camelContext”的 Spring NamespaceHandler

但是当我添加到命名空间时,我得到了以下错误:

在这一行找到多个注释: - cvc-complex-type.2.4.c:匹配通配符是严格的,但找不到元素“camelContext”的声明。 - schema_reference.4:无法读取架构文档“http://activemq.apache.org/camel/schema/spring/camel-spring.xsd”,因为 1) 无法读取 找到文件; 2) 文件无法读取; 3) 文档的根元素不是 . - 无法找到架构命名空间“http://activemq.apache.org/camel/schema/spring”的元素“camelContext”的 Spring NamespaceHandler

谁能帮我弄清楚为什么我会遇到这两个问题?我不是 xml 或骆驼方面的专家,因此将不胜感激任何帮助。 下面是我的简单xml文档:

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
      http://activemq.apache.org/camel/schema/spring     http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">



   <bean id="myrouter"      class="org.apache.camel.example.reportincident.ReportIncidentRoutes"/>



<!-- Camel Configuration -->

 <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
    <routeBuilderRef ref="myrouter"/>


 </camelContext>

</beans>

【问题讨论】:

    标签: xml spring apache-camel xml-namespaces


    【解决方案1】:

    在 Camel 1.x 中,XML 的命名空间是以 activemq 开头的,例如

    xmlns="http://activemq.apache.org/camel/schema/spring"
    

    在 Camel 2.x 中,XML 的命名空间是纯 Camel,例如

    http://camel.apache.org/schema/spring
    

    由于 Camel 1.x 已停产,我假设您使用的是 Camel 2.x。如果是这样,您需要将 标记中的命名空间更改为 2.x 样式。并删除 XML 文件顶部的旧引用。

    【讨论】:

    • 非常感谢。您是偶然在 apache camel 网站上编写报告事件教程的人吗?到目前为止,它提供了很大的帮助,但我希望您已经完成了关于使用 Spring xml 进行路由的部分。知道什么时候完成吗?
    • 啊,是的,我在 4.5 - 5 年前写的旧教程。 camel.apache.org/tutorial-example-reportincident.html - 源代码在这里 svn.apache.org/repos/asf/camel/trunk/examples/… 并且已经更新到当前版本。
    • 谢谢!我在理解如何从 Java 路由构建转换为使用 spring 进行路由时遇到了很多问题。我只是看了一下这个来源,这将有很大帮助。感谢您为制作该教程付出的所有努力!
    • 骆驼 2.11.0 仍然有同样的问题。有什么帮助吗?
    • @hoshang.varshney 有点晚了,但是您需要将其添加到 xsi:schemaLocation 属性上的 beans 标记中:camel.apache.org/schema/springcamel.apache.org/schema/spring/camel-spring.xsd
    【解决方案2】:

    谢谢!我有旧版本的 JBoss Fuse 6.2.1,我的路线运行良好。但在 JBoss Fuse 6.2.1 中,我得到了 XML 没有拾取 标签。在我将 http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd 添加到 xsi:schemaLocation 之后,它就可以工作了!!!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-02
      • 2015-07-10
      • 2011-11-24
      • 2015-01-10
      • 1970-01-01
      相关资源
      最近更新 更多