【问题标题】:Unable to setup broker-bean for ActiveMQ无法为 ActiveMQ 设置代理 bean
【发布时间】:2011-03-28 15:27:14
【问题描述】:

我在通过 xBean 解析的外部 XML 文件配置 ActiveMQ 代理时遇到问题。在这一点上,任何帮助、提示、指示、提示或什至欢呼都会受到赞赏。这是我的问题:

我正在尝试使用外部 .xml 文件来配置代理。我的 spring bundle 上下文中有以下代码:

<bean id="brokerFactory" class="org.apache.activemq.xbean.BrokerFactoryBean">  
 <property name="config" value="file:c:/activemq.xml" />  
 <property name="start" value="false" />  
</bean>

这应该与配置文件链接,没有其他问题。这是我的 activemq.xml 文件的样子:

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

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>

 <amq:broker useJmx="true" xmlns="http://activemq.apache.org/schema/core">

    <networkConnectors>
      <!-- 
      <networkConnector uri="multicast://default?initialReconnectDelay=100" />
      <networkConnector uri="static://(tcp://localhost:61616)" />
       -->
    </networkConnectors>

    <persistenceFactory>
      <journalPersistenceAdapterFactory journalLogFiles="5" dataDirectory="${basedir}/target/foo" />

    </persistenceFactory>

    <transportConnectors>
      <transportConnector uri="tcp://localhost:61636" />
    </transportConnectors>
  </amq:broker>
</beans>

如您所见,这是一个非常标准的。开始我的捆绑包时,我得到以下异常:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name     'brokerManager' defined in URL [bundle://7.0:0/META-INF/spring/bundle-context.xml]: Cannot resolve reference to bean 'brokerFactory' while setting  bean property 'brokerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'brokerFactory' defined in URL [bundle://7.0:0/META-INF/spring/bundle-context.xml]: Invocation of init method failed; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 10 in XML document from OSGi resource[file:c:/activemq.xml|bnd.id=7|bnd.sym=genericenqueuer-engine] 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'.

我已经为所涉及的命名空间尝试了几种配置。使用带有和不带有 "amq:" 声明(&lt;broker&gt;&lt;amq:broker&gt;)的代理标签,并为 activemq .xsd 声明指定特定的版本号。不过,似乎没有找到 .xsd 文件。如果我提供 activemq .xsd 文件的版本号,我会得到这个:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'brokerFactory' defined in URL [bundle://7.0:0/META-INF/spring/bundle-context.xml]: Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Unrecognized xbean namespace mapping: http://activemq.apache.org/schema/core

我使用的是 xbean-spring 3.7 版,可以在 here 找到。我尝试从我的 com.springsource.org.apache.activemq-5.3.0.jar 捆绑文件中提取 .xsd 文件并将其导出到我的一个捆绑包中的一个包中,但解析器似乎仍然找不到它。我还在 Geronimo Jira 上针对该问题发布了一个错误。

谁能解释一下这个问题?

提前致谢,
爱德华多。

【问题讨论】:

    标签: xml osgi activemq broker springsource-dm-server


    【解决方案1】:

    你有两个选择。第一个是使用&lt;osgi:service ...&gt; 标记将brokerFactory 公开为osgi 服务,并将其导入到引用bean 的第二个包中。另一种选择是在同一个包中使用您的brokerFactory。希望对你有帮助...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-04
      • 1970-01-01
      • 2017-07-09
      • 1970-01-01
      • 2011-04-02
      • 2018-03-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多