title: Unable to Import persistence.xml within applicationContext.xml file
body: <p>I'm using eclipse juno IDE
  I have Java application which have src folder. within the folder I have:</p>
  
  <p>1) applicationContext.xml</p>
  
  <p>2) persistence.xml</p>
  
  <p>I also have DBInterface and i implemented it with JPA. 
  Now in the applicationContext.xml file I have a bean for the JPA implemention.</p>
  
  <p>When I tried to inject the bean i got an excpetion that said something like "No Persistence Provider was found". </p>
  
  <p>So I tried to import the persistence file within the applicationContext file but i'm getting another exception. </p>
  
  <p><strong>applicationContext.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:aop="http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"
     xmlns:context="http://www.springframework.org/schema/context/spring-context-2.5.xsd"
     xmlns:flow="http://www.springframework.org/schema/webflow-config/spring-webflow-config-1.0.xsd"
     xmlns:jms="http://www.springframework.org/schema/jms/spring-jms-2.5.xsd"
     xmlns:jee="http://www.springframework.org/schema/jee/spring-jee-2.5.xsd"
     xmlns:lang="http://www.springframework.org/schema/lang/spring-lang-2.5.xsd"
     xmlns:osgi="http://www.springframework.org/schema/osgi/spring-osgi.xsd"
     xmlns:tx="http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"
     xmlns:util="http://www.springframework.org/schema/util/spring-util-2.5.xsd"
     xmlns:p="http://www.springframework.org/schema/p"
  
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/aop/spring-aop-2.5.xsd/spring-spring-aop-2.5.xsd-2.5.xsd
        http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/context/spring-context-2.5.xsd/spring-spring-context-2.5.xsd-2.5.xsd
        http://www.springframework.org/schema/webflow-config/spring-webflow-config-1.0.xsd http://www.springframework.org/schema/webflow-config/spring-webflow-config-1.0.xsd/spring-spring-webflow-config-1.0.xsd-2.5.xsd
        http://www.springframework.org/schema/jms/spring-jms-2.5.xsd http://www.springframework.org/schema/jms/spring-jms-2.5.xsd/spring-spring-jms-2.5.xsd-2.5.xsd
        http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/jee/spring-jee-2.5.xsd/spring-spring-jee-2.5.xsd-2.5.xsd
        http://www.springframework.org/schema/lang/spring-lang-2.5.xsd http://www.springframework.org/schema/lang/spring-lang-2.5.xsd/spring-spring-lang-2.5.xsd-2.5.xsd
        http://www.springframework.org/schema/osgi/spring-osgi.xsd http://www.springframework.org/schema/osgi/spring-osgi.xsd/spring-spring-osgi.xsd-2.5.xsd
        http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/tx/spring-tx-2.5.xsd/spring-spring-tx-2.5.xsd-2.5.xsd
        http://www.springframework.org/schema/util/spring-util-2.5.xsd http://www.springframework.org/schema/util/spring-util-2.5.xsd/spring-spring-util-2.5.xsd-2.5.xsd"&gt;
  
  
      &lt;bean id="JPA"  class="pack.jpa.JPAQueries"/&gt;
      &lt;import resource="persistence.xml"/&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>persistence.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
  
  http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" 
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
           xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"&gt; 
           &lt;persistence-unit transaction-type="RESOURCE_LOCAL" name="MyJPA"&gt; 
               &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt; 
               &lt;class&gt;pack.bl.Travels&lt;/class&gt;
               &lt;class&gt;pack.bl.Example&lt;/class&gt; 
               &lt;properties&gt; &lt;property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/&gt; 
                   &lt;property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/taxis"/&gt; 
                   &lt;property name="javax.persistence.jdbc.password" value=""/&gt; 
                   &lt;property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/&gt; 
                   &lt;property name="javax.persistence.jdbc.user" value="root"/&gt;
               &lt;/properties&gt; 
           &lt;/persistence-unit&gt; 
  </code></pre>
  
  <p></p>
  
  <p><strong>mainClass</strong></p>
  
  <pre><code>public class Program {
  
  /**
   * @param args
   */
  public static void main(String[] args) {
  
    ApplicationContext context = new  
    ClassPathXmlApplicationContext("applicationContext.xml");
    DBInterface dao = (DBInterface)context.getBean("JPA",JPAQueries.class);
  
    dao.retrieveRecords();
  }
  </code></pre>
  
  <p><strong>Exception</strong></p>
  
  <pre><code>Exception in thread "main"  
  org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration 
  problem: Failed to import bean definitions from relative location [persistence.xml]
  
  Offending resource: class path resource [applicationContext.xml]; nested exception is 
  org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration 
  problem: Unable to locate Spring NamespaceHandler for XML schema namespace 
  [http://java.sun.com/xml/ns/persistence]
  
  Offending resource: class path resource [persistence.xml]
  at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
  at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
  at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
  at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:271)
  at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:196)
  at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:181)
  at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:140)
  at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:111)
  at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
  at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
  at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
  at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
  at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
  at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
  at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
  at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
  at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
  at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
  at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
  at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:527)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:441)
  at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:139)
  at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:83)
  at pack.program.Program.main(Program.java:16)
  
  Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://java.sun.com/xml/ns/persistence]
  
  Offending resource: class path resource [persistence.xml]
  
  at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
  at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
  at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
  at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:317)
  at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1428)
  at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1421)
  at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:190)
  at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:140)
  at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:111)
  at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
  at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
  at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
  at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
  at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:255)
  ... 20 more
  </code></pre>