1

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?

Marco
  • 15,101
  • 33
  • 107
  • 174
  • Possible duplicate of [The matching wildcard is strict, but no declaration can be found for element 'context:component-scan](http://stackoverflow.com/questions/13589470/the-matching-wildcard-is-strict-but-no-declaration-can-be-found-for-element-co) – Bacteria Dec 21 '15 at 14:32
  • Is no duplicate as the schema location of the context is provided. – Marco Dec 21 '15 at 14:38
  • Some kind of classloader/classpath problem, perhaps; try running the JVM with `-verbose` to see if it gives you any clues. – Gary Russell Dec 21 '15 at 15:22
  • 1
    There is a blog post for using Spring in HiveMQ Plugins at http://www.hivemq.com/blog/using-spring-in-hivemq-plugins. maybe it helps – Schäbo Jan 27 '16 at 13:39

0 Answers0