Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring, JMS - Unable to locate Spring NamespaceHandler for XML schema namespace

Over and over I'm getting this error:

10:37:21,270 ERROR DispatcherServlet:466 - Context initialization failed org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://activemq.apache.org/schema/core] Offending resource: ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]

I've tried many pom.xml and spring configurations, but none of them worked so far.

Here are dependencies in my pom.xml:

<dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jms</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-core</artifactId>
            <version>5.7.0</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.2.6.Final</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-ehcache</artifactId>
            <version>4.2.6.Final</version>
        </dependency>
        <dependency>
            <groupId>com.networkwatcher</groupId>
            <artifactId>NetworkWatcherJMS</artifactId>
            <version>1.0</version>
        </dependency>
    </dependencies>

And here is my servlet config:

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:amq="http://activemq.apache.org/schema/core"
   xmlns:jms="http://www.springframework.org/schema/jms"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:context="http://www.springframework.org/schema/context"
   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/jms
                       http://www.springframework.org/schema/jms/spring-jms.xsd
                       http://activemq.apache.org/schema/core
                       http://activemq.apache.org/schema/core/activemq-core-5.8.0.xsd">


<context:annotation-config />

<context:component-scan base-package="com.networkwatcher"/>

<bean id="localeResolver"
      class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
    <property name="defaultLocale" value="en" />
</bean>

<bean id="messageSource"
      class="org.springframework.context.support.ResourceBundleMessageSource">
      <property name="basename" value="messages" />
</bean>


<amq:connectionFactory id="amqConnectionFactory" brokerURL="http://192.168.0.105:9090/nw/message" />

<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
    <constructor-arg ref="amqConnectionFactory" />
    <property name="sessionCacheSize" value="100" />
</bean>

<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <constructor-arg ref="connectionFactory"/>
</bean>

<bean id="messageReceiver" class="com.networkwatcher.MessageReceiver" />

<jms:listener-container concurrency="1" >
    <jms:listener id="queueReceiver" destination="signal" ref="messageReceiver"  />
</jms:listener-container>

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/Views/"/>
    <property name="suffix" value=".jsp"/>
</bean>

Could anyone tell we what is wrong in here and how to fix it?

like image 558
mattis Avatar asked Oct 17 '13 08:10

mattis


2 Answers

You are missing the entry for activemq-spring

<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-spring</artifactId>
    <version>5.8.0</version>
</dependency>
like image 98
Hussain Pirosha Avatar answered Sep 27 '22 18:09

Hussain Pirosha


I don't know why, but maven didn't download dependencies, however they were specified in pom.xml. Making mvn clean from command prompt solved the problem.

like image 32
mattis Avatar answered Sep 27 '22 17:09

mattis