XML没有拿起<camelcontext>标签</camelcontext>

时间:2013-01-16 17:42:53

标签: xml spring apache-camel xml-namespaces

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

“此行找到多个注释:      - cvc-complex-type.2.4.c:匹配的通配符是strict,但是没有为元素'camelContext'找到声明。      - 无法找到模式名称空间“http://activemq.apache.org/camel/”的元素“camelContext”的Spring NamespaceHandler

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

此行找到多个注释:      - cvc-complex-type.2.4.c:匹配的通配符是strict,但是没有为元素'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>

2 个答案:

答案 0 :(得分:7)

在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是EOL,我假设你使用的是Camel 2.x.如果是这样,你需要改变&lt;中的名称空间。 camelContext&gt;标记为2.x样式。并删除XML文件顶部的旧引用。

答案 1 :(得分:-1)

谢谢!我有旧版JBoss Fuse 6.2.1,我的路线工作正常。但是在JBoss Fuse 6.2.1中我得到了 XML没有接收&lt; camelContext&gt;标签即可。我将http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd添加到xsi:schemaLocation之后就可以了!

相关问题