title: Spring Tool Suite application context xml errors even though all beans seem to work as they should
body: <p>I'm configuring jpa and jpa repositories inside one of spring app context xmls. </p>
  
  <p>If I have both  <code>&lt;jpa:repositories base-package="..." /&gt;</code> and <code>&lt;context:component-scan base-package="..." /&gt;</code> then Spring Tool Suite shows an error on line 1 saying</p>
  
  <p><code>Referenced file contains errors (http://www.springframework.org/schema/context/spring-context-4.0.xsd). For more information, right click on the message in 
   the Problems View and select "Show Details..."</code></p>
  
  <p>and upon clicking show details i get this:</p>
  
  <pre><code>The errors below were detected when validating the file "spring-context-4.0.xsd" viathe file "app-config.xml".  In most cases these errors can be detected by validating "spring-context-4.0.xsd" directly.  However it is possible that errors will only occur when spring-context-4.0.xsd is validated in the context of app-config.xml.
  
  sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/context,propertyPlaceholder'.  line 22
  
  sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/context,property-placeholder'.  line 91
  
  sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/context,property-override'.  line 155
  
  sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/context,annotation.config'.  line 174
  
  sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/context,component-scan'.  line 194
  
  sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/context,load-time-weaver'.  line 315
  
  sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/context,spring-configured'.  line 392
  
  sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/context,mbean-export'.  line 405
  
  sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/context,mbean-server'.  line 458
  
  sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/context,filterType'.  line 488
  </code></pre>
  
  <p>And beside <code>&lt;jpa:repositories base-package="..." /&gt;</code> there's a warning saying <code>Referenced bean 'jpaMapppingContext' not found</code></p>
  
  <p>Running the application it seems to be working correctly. I can connect to the db and using JpaRepository interface I'm able to fetch data from the db, so I'm unsure why am I presented with a fatal error in STS. I'm assuming that since both jpa:repositories and context:component-scan scan packages that there is some duplication/conflicts when both are used but I'm unsure on how should I approach to fixing it (I could probably split services into their own config xml and either import it in app config or add it to context list in web.xml)</p>
  
  <p>Here is the app-config.xml in its entirety:</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:tx="http://www.springframework.org/schema/tx"
      xmlns:p="http://www.springframework.org/schema/p"
      xmlns:util="http://www.springframework.org/schema/util"
      xmlns:jpa="http://www.springframework.org/schema/data/jpa"
      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-4.0.xsd
          http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd"&gt;
  
      &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"
      p:driverClassName="org.h2.Driver"
      p:url="jdbc:h2:tcp://localhost/~/test;INIT=CREATE SCHEMA IF NOT EXISTS TEST"
      p:username="sa"
      p:password="" /&gt;
  
      &lt;bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" 
      p:showSql="true" /&gt;
  
      &lt;util:map id="jpaProperties"&gt;
          &lt;entry key="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" /&gt;
          &lt;entry key="hibernate.hbm2ddl.auto" value="update" /&gt;
          &lt;entry key="hibernate.default_schema" value="test" /&gt;
      &lt;/util:map&gt;
  
      &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
      p:dataSource-ref="dataSource"
      p:packagesToScan="hr.mrplow.test.model"
      p:jpaVendorAdapter-ref="jpaVendorAdapter"
      p:jpaProperties-ref="jpaProperties" /&gt;  
  
      &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
      p:entityManagerFactory-ref="entityManagerFactory"
      p:rollbackOnCommitFailure="true" /&gt;
  
      &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;       
  
      &lt;jpa:repositories base-package="hr.mrplow.test.DAO" /&gt;
  
      &lt;!-- Services --&gt;
      &lt;context:component-scan base-package="hr.mrplow.test.service" /&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>Here's the full app-config.xml</p>