Spring / OSGi中嵌入式ActiveMQ代理问题

时间:2010-05-19 21:50:24

标签: spring jms osgi activemq

我遇到了一个非常令人不安的问题,一直困扰着我,我想知道是否有人能给我一些见解。

基本上,我要做的是在我的一个OSGi包(在Felix中)的Spring上下文中设置一个嵌入式ActiveMQ代理。我已经下载了this页面中列出的捆绑包和所有依赖项。它们都在运行。这是我的Spring上下文xml文件的样子:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:jms="http://www.springframework.org/schema/jms"
xmlns:amq="http://activemq.apache.org/schema/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/osgi-compendium http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd 
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
    http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-2.5.xsd
    http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">

<!-- some uninteresting parts ommited -->

<!-- JMS Configurations -->

<amq:broker useJmx="false" start="true">
  <amq:transportConnectors>
    <amq:transportConnector uri="tcp://localhost:0"/>
  </amq:transportConnectors>
</amq:broker>

<!-- other ActiveMQ configs such as destinations and whatnot  -->

这对我来说非常好。但是,在启动期间,我收到以下消息:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 41 in XML document from URL [bundle://121.0:0/META-INF/spring/bundle-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'amq:broker'.

我发现有人在Eclipse中遇到过类似的问题(我也在使用它),他们显然通过让Eclipse指向ActiveMQ jar中的捆绑.xsd文件来解决它。我试图做同样的事,唉,无济于事。

有没有人对我在这里失踪的内容有任何想法?

提前致谢。

3 个答案:

答案 0 :(得分:4)

只是为了给大家一些反馈,通过指定activemq xsd的版本号,问题早就解决了,例如:

http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.2.0.xsd"

然而,我还没有加载这样的配置(虽然我没有留下编程,正如我们的朋友建议的那样研究华丽的锡兰木鸽交配仪式,尽管我现在正在认真思考)。我现在正在使用在我的应用程序之外运行的代理,因此加载配置会有所不同。

答案 1 :(得分:1)

如果不仔细查看您的具体问题,我建议您使用细齿梳来查看xmlns:*和xsi:schemalocation = ...行。你可能会发现意想不到的东西。

答案 2 :(得分:0)

列出捆绑包&#39; org.apache.activemq-core&#39; (例如,&#39;捆绑88&#39;在equinox中),并查找它导出activemq.xsd文件的路径(启动META-INF ...),并确保您的包与amq代理xml config导入它(例如,将其添加到osgi.bnd的Import-Packages:)