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

2

6

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?

Inge answered 17/10, 2013 at 8:45 Comment(0)
M
21

You are missing the entry for activemq-spring

<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-spring</artifactId>
    <version>5.8.0</version>
</dependency>
Machute answered 17/10, 2013 at 8:54 Comment(5)
For activemq.apache.org/schema/core namespace the handler class is org.apache.xbean.spring.context.v2.XBeanNamespaceHandler. I guess once you had xbean-spring jar in your classpath then this issue got resolved.Machute
@mattis: Were you able to solve it? I'm facing similar problem.Aldon
And you have xbean-spring on the classpath also?Penitence
This was it. If you were using a config with activemq-core, java-jms and spring-jms only you will have to include this one to from now on. I guess they removed this dependency from spring-jms so you have to include this manually.Sorghum
I'd recommend this answer be extended to include that you also need the xbean dependencyMariettemarigold
I
1

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.

Inge answered 17/10, 2013 at 10:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.