I am trying to integrate Spring into a HiveMQ (MQTT broker) plugin. I have managed to load the spring-context and beans are actually scanned and can be autowired using @Inject instead of @Autowire.
When i try to use Spring-Rabbit inside this plugin, the Spring framework complains that it cannot deal correctly with the xml in my spring-context.xml.
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'rabbit:connection-factory'.
The spring-context is as follows:
<?xml version='1.0' encoding='UTF-8'?>
<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:rabbit="http://www.springframework.org/schema/rabbit"
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-4.0.xsd
http://www.springframework.org/schema/rabbit
http://www.springframework.org/schema/rabbit/spring-rabbit.xsd'>
<context:component-scan base-package="com.acme"/>
<rabbit:connection-factory id="connectionFactory"
addresses='localhost'
username='username'
password='password'
virtual-host='vhost'/>
</beans>
I load the context as follows:
ClassLoader classLoader = this.getClass().getClassLoader();
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext();
ctx.setClassLoader(classLoader);
ctx.setConfigLocation("spring-context.xml");
ctx.refresh();
When i start the application normally without the context of the HiveMQ plugin it can find everything needed.
Any hint where to look for?