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

发布于 2024-09-02 04:20:40 字数 2684 浏览 7 评论 0原文

我遇到了一个非常令人不安的问题,这个问题一直困扰着我一段时间,我想知道是否有人可以给我一些关于这个问题的见解。

基本上,我想做的是在我的一个 OSGi 包(在 Felix 中)的 Spring 上下文中设置一个嵌入式 ActiveMQ 代理。我已经下载了该捆绑包以及 页面。它们都已启动并运行。我的 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 文件来解决该问题。我也尝试做同样的事情,可惜没有成功。

有人对我在这里可能缺少的东西有任何想法吗?

提前致谢。

I ran into a very disturbing issue that's been puzzling me for a while and I was wondering if anyone could give me some insight on this.

Basically, what I'm trying to do is set up an embedded ActiveMQ broker in the Spring context of one of my OSGi bundles (in Felix). I have downloaded the bundle and all dependencies listed in this page. They are all up and running. Here's what my Spring context xml file looks like:

<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  -->

This looks pretty ok to me. However, during the startup I get the following message:

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'.

I've found someone experiencing a similar issue in Eclipse (which I'm also using) and they apparently solved it by making Eclipse point to the bundled .xsd file in the ActiveMQ jar. I attempted to do the same, alas, to no avail.

Does anybody have any ideas on what i might be missing here?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

壹場煙雨 2024-09-09 04:20:40

只是为了给你们一些反馈,不久前通过指定 activemq xsd 的版本号解决了问题,例如:

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

但是我还没有再加载这样的配置(尽管我没有留下编程来研究)正如我们的朋友建议的那样,宏伟的锡兰林鸽交配仪式,尽管我现在正在认真考虑)。我现在正在使用在我的应用程序外部运行的代理,因此加载配置的方式有点不同。

Just to give you guys some feedback, the problem was solved a while ago by specifying the version number for the activemq xsd, e.g.:

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

However I haven't been loading the configs like that anymore (though I didn't leave programming behind to research the magnificent Ceylon Wood Pigeon mating rituals as our friend suggested, though I'm seriously considering to now). I am now working with the broker running outside my application, so loading the configurations is done a bit different.

飘然心甜 2024-09-09 04:20:40

在不仔细研究您的具体问题的情况下,我建议您仔细检查 xmlns:* 和 xsi:schemalocation=... 行。你可能会发现一些意想不到的东西。

Without looking too closely at your specific problem I'd recommend going over the xmlns:* and xsi:schemalocation=... lines with a fine tooth comb. You might just find something unexpected.

最舍不得你 2024-09-09 04:20:40

列出包“org.apache.activemq-core”(例如,春分时的“bundle 88”),并查找导出 activemq.xsd 文件的路径(启动 META-INF...),并确保带有 amq 代理 xml 配置的捆绑包会导入它(例如,将其添加到 osgi.bnd 的 Import-Packages: 中)

List the bundle 'org.apache.activemq-core' (e.g., 'bundle 88' in equinox), and look for the path under which it exports the activemq.xsd file (starts META-INF...), and ensure that your bundle with the amq broker xml config imports it (add it to the Import-Packages: of the osgi.bnd, for example)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文