我一直在通过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'.
我已经为所涉及的namaspace尝试了几种配置。使用带有和不带"amq:"
声明(<broker>
和<amq:broker>
)的代理标记,并指定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上发布了一个关于该问题的错误。
有人能解释一下这个问题吗?
提前致谢,
爱德华。
答案 0 :(得分:1)
您有两种选择。第一种是使用brokerFactory
标记将您的<osgi:service ...>
公开为osgi服务,并将其导入您引用bean的第二个包中。另一种选择是在同一捆绑中使用您的brokerFactory
。希望它有所帮助...