0

我正在尝试运行骆驼示例“camel-example-spring-jms”(也在http://activemq.apache.org/camel/tutorial-jmsremoting.html)。但是,当我尝试使用“org.apache.camel.spring.Main”类启动 Camel 时,我收到错误消息

“配置问题:找不到 XML 模式命名空间的 Spring NamespaceHandler [ http://activemq.apache.org/schema/core]

[注意:当我使用 Maven 命令 "mvn exec:java -PCamelServer" 时,我能够很好地运行该示例]

有人可以帮助我了解可能导致这种情况的原因。潜在的解决方案提示也不会受到伤害:)

++++++ 错误堆栈 +++++

Dec 4, 2008 12:45:01 PM org.apache.camel.util.MainSupport doStart
INFO: Apache Camel 1.5.0 starting
Dec 4, 2008 12:45:01 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1ac3c08: display name [org.springframework.context.support.ClassPathXmlApplicationContext@1ac3c08]; startup date [Thu Dec 04 12:45:01 EST 2008]; root of context hierarchy
Dec 4, 2008 12:45:01 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from file [C:\dev\camel-example-spring-jms\bin\META-INF\spring\camel-server-aop.xml]
Dec 4, 2008 12:45:02 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from file [C:\dev\camel-example-spring-jms\bin\META-INF\spring\camel-server.xml]
Dec 4, 2008 12:45:03 PM org.apache.camel.util.MainSupport run
SEVERE: Failed: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [camel-server.xml]
Offending resource: file [C:\dev\camel-example-spring-jms\bin\META-INF\spring\camel-server-aop.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://activemq.apache.org/schema/core]
Offending resource: file [C:\dev\camel-example-spring-jms\bin\META-INF\spring\camel-server.xml]

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [camel-server.xml]
Offending resource: file [C:\dev\camel-example-spring-jms\bin\META-INF\spring\camel-server-aop.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://activemq.apache.org/schema/core]
Offending resource: file [C:\dev\camel-example-spring-jms\bin\META-INF\spring\camel-server.xml]

        at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
        at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
        at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:201)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:147)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:132)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
        at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:113)
        at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:80)
        at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
        at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:423)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:353)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
        at org.apache.camel.spring.Main.createDefaultApplicationContext(Main.java:189)
        at org.apache.camel.spring.Main.doStart(Main.java:152)
        at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:47)
        at org.apache.camel.util.MainSupport.run(MainSupport.java:121)
        at org.apache.camel.util.MainSupport.run(MainSupport.java:310)
        at org.apache.camel.spring.Main.main(Main.java:72)

++++++

4

5 回答 5

1

所以它在 maven 下运行良好 - 但如果你运行它就不行了?在你的IDE还是什么的?

如果您使用的是 eclipse / intellij,您可以使用 maven 为 maven 项目创建一个 IDE 项目。

mvn eclipse:eclipse

或者

mvn idea:idea

如果您正在编写一些 shell 脚本或从命令行运行它,那么您很可能缺少一些 jar;你需要 spring + jaxb + commons-logging + camel-core、camel-spring 和 camel-jms。

获取 maven 类型中依赖项的准确列表

mvn dependency:tree
于 2008-12-05T08:50:05.487 回答
0

当 camel-jms 库 .jar 不在您的类路径上时,会导致此特定异常。正如 James 所提到的,确保该库在运行时正确位于您的类路径中。

于 2008-12-16T19:45:10.997 回答
0

我在使用骆驼时遇到了类似的问题(尽管它是骆驼 1.3)。就我而言,错误是:

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate NamespaceHandler for namespace [http://activemq.apache.org/camel/schema/spring]

我能够通过更改我的 jdk 版本来修复它。我使用的是 jdk 1.5,我升级到 1.6 并解决了我的问题。希望这可以帮助。

莫妮卡

于 2008-12-31T21:37:06.623 回答
0

你用的是哪个版本的JDK1.5?您是否在 Eclipse 和命令行中使用不同的 JDK?

可能是 JAXB 没有正确版本的问题。必须是 JAXB 2.1 或更新版本。

于 2009-01-18T09:12:03.677 回答
0

在 Eclipse 内部和使用外部工具(Maven)时,我都遇到了同样的问题。正如 James 和 Pete 指出的那样,在类路径中添加 camel-jms.jar 解决了我的问题。看起来 camel-core 和 camel-jms 是基本的强制依赖项:

<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-core</artifactId>
  <version>1.6.0</version>
  <scope>compile</scope>
</dependency>

<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-jms</artifactId>
  <version>1.6.0</version>
  <scope>runtime</scope>
</dependency>
于 2009-04-21T16:30:35.880 回答