简体   繁体   中英

Unable to setup broker-bean for ActiveMQ

I've been having problems configuring an ActiveMQ broker through an xBean-parsed external XML file. At this point, ANY help, tips, pointers, hints or even cheering-up are appreciated. Here's my issue:

I'm trying to use an external .xml file to configure a broker. I have the following code in my spring bundle context:

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

This should link with the configuration file with no further problems. Here is what my activemq.xml file looks like:

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

As you can see it's a pretty standard one. When starting out my bundles I get the following exception:

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

I have tried several configurations for the namaspaces involved. Using the broker tags with and without the "amq:" declaration ( <broker> and <amq:broker> ) and specifying the specific version number for the activemq .xsd declaration. Still, the .xsd file doesn't seem to be found. If I provide the version number for the activemq .xsd file I get this instead:

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

I am using xbean-spring version 3.7 which can be found here . I have tried extracting the .xsd file from my com.springsource.org.apache.activemq-5.3.0.jar bundle file and exporting it on a package in one of my bundles but the parser still can't seem to find it. I have also posted a bug on the Geronimo Jira for the issue.

Can anyone shed some light on the issue?

Thanks in advance,
Eduardo.

You have two options. The first is to expose your brokerFactory as an osgi service using the <osgi:service ...> tags and importing it in your second bundle where you reference the bean. The other option is to use your brokerFactory in the same bundle. Hope it helps...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM