Embedded ActiveMQ broker in Spring/OSGi problems
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="htt开发者_StackOverflow社区p://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.
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.
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.
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)
精彩评论