0
votes

I am getting the following exception on a Spring project.Even I tried several solutions suggested in stackoverflow I could not resolve yet. Could you please help me ?

java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate NamespaceHandler for namespace [http://www.springframework.org/schema/context] Offending resource: class path resource [springDAO.xml]

SpringDao.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:amq="http://activemq.org/config/1.0"    
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://activemq.org/config/1.0 http://activemq.apache.org/schema/core/activemq-core-5.0-SNAPSHOT.xsd"
default-autowire="autodetect">

<!-- Database -->
<bean id="ds" class="org.springframework.jndi.JndiObjectFactoryBean" autowire="no">
    <property name="jndiName" value="java:comp/env/jdbc/datasource" />
</bean>   

<bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="ds" />
    <property name="persistenceUnitName" value="NewstrackPU"/>
    <property name="loadTimeWeaver">
        <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
    </property>
    <property name="jpaVendorAdapter">
        <bean
            class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">                
        </bean>
    </property>        
    <property name="jpaDialect">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
    </property>
</bean>

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<!-- tx:annotation-driven configure transactions on any beans with @Transactional, and just after the JPA transaction manager is setup. -->
<tx:annotation-driven transaction-manager="transactionManager"/>
<context:component-scan base-package ="com.abc.newstrack.dao"/>
<context:component-scan base-package ="com.abc.newstrack.service"/>

Spring Dependencies

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring</artifactId>
        <version>2.5.6.SEC03</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>2.5.6.SEC03</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>2.5.6.SEC03</version>
    </dependency>
1
You have both spring and spring-context on your classpath. Don't, either use spring (which contains almost everything) or use seperate modules (spring-context etc.). Also make sure you don't have conflicting spring versions in yuor classpath (check with mvcn depenency:tree).M. Deinum
Thanks Deinum. It seems like a conflicting problem and I am resolving it.Duleendra

1 Answers

0
votes

I downloaded the activemq-core-5.0-SNAPSHOT pom.xml. It uses Spring 2.0.6 as the dependencies. I see that you have Spring 2.5.6 SEC02 as your spring dependencies.

Based on the activeMQ pom file i would believe you would have to use spring 2.0.6 as the dependencies and not 2.5.6?

As for the actual problem of your namespace not being resolved, it is generally a problem with the dependencies not being present in the classpath. In this case since active mq uses Spring 2.0.6 it isnt there in the classpath.