I am getting an exception in one of my configuration file "spring-jpa.xml".Can anyone tell me whats wrong?I have checked for similar questions but whatever i got,it didnot solve the problem.
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [spring-jpa.xml]
Offending resource: ServletContext resource [/WEB-INF/dispatcher-servlet.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/data/jpa]
Offending resource: ServletContext resource [/WEB-INF/spring-jpa.xml]
Following is the file where i am getting the exception:
spring-jpa.xml
<?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:jee="http://www.springframework.org/schema/jee"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa-1.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd">
<!-- JPA Configurations -->
<jee:jndi-lookup id="letsCatchUpDataSource" jndi-name="jdbc/LetsCatchUpDB"/>
<!-- ookup-on-startup="false" proxy-interface="javax.sql.DataSource" -->
<!-- Used for transaction management -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" />
<!-- Enable transactional based annotations -->
<tx:annotation-driven transaction-manager="transactionManager" />
<!-- PersistenceAnnotationBeanPostProcessor : One of its duties is to search the proper entity EntityManagerFactory that would provide the EntityManager for you @PersistenceContext annotated properties -->
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<!-- Used to set up Entity Manager -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<!-- org.hibernate.ejb.HibernatePersistence is deprecated.Use org.hibernate.jpa.HibernatePersistenceProvider instead.-->
<property name="persistenceProviderClass" value="org.hibernate.ejb.HibernatePersistence" />
<property name="dataSource" ref="letsCatchUpDataSource" />
<property name="persistenceUnitName" value="letsCatchUpPU" />
<property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" />
</bean>
<jpa:repositories base-package="com.letscatchup.repository"
entity-manager-factory-ref="entityManagerFactory"
transaction-manager-ref="transactionManager"/>
</beans>
The error is saying it is not able to load the
spring-jpa.xml
. Place the spring-jpa.xml in the /src folder for contextLoader to find it. Else if you are placing your spring in web inf then incontextConfigLocation
give relative path from/WEB-INF/..
e.g.,