title: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/batch]
body: <h3>Situation</h3>
  <p>I am using Spring Batch to build an Accumulative Snapshot for our Data Warehouse and I am having a configuration roadblock that I cannot figure out.</p>
  <p>I have created a Simple Spring Batch Project with STS (SpringSource Tool Suite 2.8.1) using the <strong>Spring Template Project</strong>. These were my two xml configuration files created:</p>
  <p><strong>launch-context.xml</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
  xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; 
  xmlns:batch=&quot;http://www.springframework.org/schema/batch&quot;
  xmlns:context=&quot;http://www.springframework.org/schema/context&quot;
  xmlns:jdbc=&quot;http://www.springframework.org/schema/jdbc&quot;
  xsi:schemaLocation=&quot;
      http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd
      http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd&quot;&gt;
  
  &lt;context:property-placeholder location=&quot;classpath:batch.properties&quot; /&gt;
  
  &lt;context:component-scan base-package=&quot;edu.kdc.visioncards&quot; /&gt;
  
  &lt;jdbc:initialize-database data-source=&quot;dataSource&quot;&gt;
      &lt;jdbc:script location=&quot;${batch.schema.script}&quot; /&gt;
  &lt;/jdbc:initialize-database&gt;
  
  &lt;batch:job-repository id=&quot;jobRepository&quot; /&gt;
  
  &lt;import resource=&quot;classpath:/META-INF/spring/module-context.xml&quot; /&gt;
  </code></pre>
  
  <p>and <strong>module-context.xml</strong></p>
  <pre><code> &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
  xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
  xmlns:batch=&quot;http://www.springframework.org/schema/batch&quot;
  xsi:schemaLocation=&quot;http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd&quot;&gt;
  
  &lt;description&gt;Example job to get you started. It provides a skeleton for a typical batch application.&lt;/description&gt;
  
  &lt;batch:job id=&quot;job1&quot;&gt;
      &lt;batch:step id=&quot;step1&quot;  &gt;           
          &lt;batch:tasklet transaction-manager=&quot;transactionManager&quot; start-limit=&quot;100&quot; &gt;
              &lt;batch:chunk reader=&quot;reader&quot; writer=&quot;writer&quot; commit-interval=&quot;1&quot; /&gt;
          &lt;/batch:tasklet&gt;
      &lt;/batch:step&gt;
  &lt;/batch:job&gt; 
  
  &lt;/beans&gt;
  </code></pre>
  <h3>Problem</h3>
  <p>I run the following command to compile and package the project: <strong>mvn clean compile install</strong></p>
  <p>then I do as follows:</p>
  <ol>
  <li><p><strong>cd</strong> to <strong>target</strong> folder</p>
  </li>
  <li><p>Run the job through CommandLineJobRunner: <strong>java -jar batchprimer-1.0.jar META-INF/spring/module-context.xml job1</strong></p>
  </li>
  </ol>
  <p>and I get the following error:</p>
  <pre><code>C:\stsworkspace\BatchPrimer\target&gt;java -jar batchprimer-1.0.jar META-INF/spring
  /module-context.xml job1
  2011-12-15 12:03:53,421 INFO [org.springframework.context.support.ClassPathXmlAp
  plicationContext] - &lt;Refreshing org.springframework.context.support.ClassPathXml
  ApplicationContext@84abc9: startup date [Thu Dec 15 12:03:53 EST 2011]; root of
  context hierarchy&gt;
  2011-12-15 12:03:53,468 INFO [org.springframework.beans.factory.xml.XmlBeanDefin
  itionReader] - &lt;Loading XML bean definitions from class path resource [META-INF/
  spring/module-context.xml]&gt;
  2011-12-15 12:03:53,796 ERROR [org.springframework.batch.core.launch.support.Com
  mandLineJobRunner] - &lt;Job Terminated in error: Configuration problem: Unable to
  locate Spring NamespaceHandler for XML schema namespace [http://www.springframew
  ork.org/schema/batch]
  Offending resource: class path resource [META-INF/spring/module-context.xml]
  &gt;
  org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Config
  uration problem: Unable to locate Spring NamespaceHandler for XML schema namespa
  ce [http://www.springframework.org/schema/batch]
  Offending resource: class path resource [META-INF/spring/module-context.xml]
  
          at org.springframework.beans.factory.parsing.FailFastProblemReporter.err
  or(FailFastProblemReporter.java:68)
          at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderC
  ontext.java:85)
          at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderC
  ontext.java:80)
          at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.er
  ror(BeanDefinitionParserDelegate.java:284)
          at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.pa
  rseCustomElement(BeanDefinitionParserDelegate.java:1335)
          at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.pa
  rseCustomElement(BeanDefinitionParserDelegate.java:1328)
          at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentRe
  ader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135)
          at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentRe
  ader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:93)
          at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registe
  rBeanDefinitions(XmlBeanDefinitionReader.java:493)
          at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadB
  eanDefinitions(XmlBeanDefinitionReader.java:390)
          at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBea
  nDefinitions(XmlBeanDefinitionReader.java:334)
          at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBea
  nDefinitions(XmlBeanDefinitionReader.java:302)
          at org.springframework.beans.factory.support.AbstractBeanDefinitionReade
  r.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
          at org.springframework.beans.factory.support.AbstractBeanDefinitionReade
  r.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
          at org.springframework.beans.factory.support.AbstractBeanDefinitionReade
  r.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
          at org.springframework.beans.factory.support.AbstractBeanDefinitionReade
  r.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
          at org.springframework.context.support.AbstractXmlApplicationContext.loa
  dBeanDefinitions(AbstractXmlApplicationContext.java:126)
          at org.springframework.context.support.AbstractXmlApplicationContext.loa
  dBeanDefinitions(AbstractXmlApplicationContext.java:92)
          at org.springframework.context.support.AbstractRefreshableApplicationCon
  text.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
          at org.springframework.context.support.AbstractApplicationContext.obtain
  FreshBeanFactory(AbstractApplicationContext.java:467)
          at org.springframework.context.support.AbstractApplicationContext.refres
  h(AbstractApplicationContext.java:397)
          at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;i
  nit&gt;(ClassPathXmlApplicationContext.java:139)
          at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;i
  nit&gt;(ClassPathXmlApplicationContext.java:83)
          at org.springframework.batch.core.launch.support.CommandLineJobRunner.st
  art(CommandLineJobRunner.java:282)
          at org.springframework.batch.core.launch.support.CommandLineJobRunner.ma
  in(CommandLineJobRunner.java:574)
  </code></pre>
  <h3>Additional Stuff</h3>
  <p>In the target folder that got populated with the mvn install command I have as follows:</p>
  <ol>
  <li>A <strong>classes</strong> folder</li>
  <li>a <strong>lib</strong> folder with all my maven dependencies</li>
  <li>a <strong>maven-archiver</strong> folder</li>
  <li>a <strong>test-classes</strong> folder</li>
  <li>a <strong>batchprimer-1.0.jar</strong></li>
  </ol>
  <p>Inside the jar, in the <strong>META-INF/MANIFEST.MF</strong>. I have as follows:</p>
  <pre><code>Manifest-Version: 1.0
  
  Archiver-Version: Plexus Archiver
  
  Created-By: Apache Maven
  
  Built-By: dpardo
  
  Build-Jdk: 1.6.0_20
  
  Main-Class: org.springframework.batch.core.launch.support.CommandLineJ
   obRunner
  
  Class-Path: lib/spring-jdbc-3.0.6.RELEASE.jar lib/spring-beans-3.0.6.R
   ELEASE.jar lib/spring-core-3.0.6.RELEASE.jar lib/spring-asm-3.0.6.REL
   EASE.jar lib/commons-logging-1.1.1.jar lib/spring-tx-3.0.6.RELEASE.ja
   r lib/aopalliance-1.0.jar lib/spring-aop-3.0.6.RELEASE.jar lib/spring
   -context-3.0.6.RELEASE.jar lib/spring-expression-3.0.6.RELEASE.jar li
   b/cglib-nodep-2.2.jar lib/spring-batch-core-2.1.7.RELEASE.jar lib/spr
   ing-batch-infrastructure-2.1.7.RELEASE.jar lib/xstream-1.3.jar lib/xp
   p3_min-1.1.4c.jar lib/jettison-1.1.jar lib/commons-io-1.4.jar lib/com
   mons-dbcp-1.2.2.jar lib/commons-pool-1.3.jar lib/hsqldb-1.8.0.7.jar l
   ib/aspectjrt-1.6.8.jar lib/aspectjweaver-1.6.8.jar lib/log4j-1.2.14.j
   ar lib/slf4j-log4j12-1.5.8.jar lib/slf4j-api-1.5.8.jar lib/mysql-conn
   ector-java-5.1.3.jar
  </code></pre>
  <p>So I do not think that it is a classpath issue because in the console it seems like it's finding the jars.</p>
  <h3>What I have tried</h3>
  <p>Based on the error, I pasted the following URL</p>
  <p><a href="http://www.springframework.org/schema/batch/" rel="noreferrer">http://www.springframework.org/schema/batch/</a></p>
  <p>and the address of the namespaces for Spring Batch seems to be correct. I have not found anything useful neither out there. I read somewhere that &quot;something&quot; could be overriding the namespaces of the files but did not really understand why, what, and/or how to solve it.</p>
  <p>This is just out the box and already not working without having done any modifications, add-ons or anything. Any ideas?</p>
  <p>Thanks</p>
  <h2>SOLUTION</h2>
  <p>In addition to the marked as correct solution below. I also had to change the launch-context.xml from component scanning to regular spring wiring like this below:</p>
  <pre><code>&lt;!-- Commented this 
  &lt;context:property-placeholder location=&quot;classpath:batch.properties&quot; /&gt;  
  
  
  &lt;jdbc:initialize-database data-source=&quot;dataSource&quot;&gt;
      &lt;jdbc:script location=&quot;${batch.schema.script}&quot; /&gt;
  &lt;/jdbc:initialize-database&gt;
  --&gt;
  &lt;!-- Replace it with this below --&gt;
  &lt;bean id=&quot;dataSource&quot; class=&quot;org.apache.commons.dbcp.BasicDataSource&quot;&gt;
      &lt;property name=&quot;driverClassName&quot; value=&quot;${batch.jdbc.driver}&quot; /&gt;
      &lt;property name=&quot;url&quot; value=&quot;${batch.jdbc.url}&quot; /&gt;
      &lt;property name=&quot;username&quot; value=&quot;${batch.jdbc.user}&quot; /&gt;
      &lt;property name=&quot;password&quot; value=&quot;${batch.jdbc.password}&quot; /&gt;
  &lt;/bean&gt;
  
  &lt;bean id=&quot;transactionManager&quot;
      class=&quot;org.springframework.jdbc.datasource.DataSourceTransactionManager&quot;
      lazy-init=&quot;true&quot;&gt;
      &lt;property name=&quot;dataSource&quot; ref=&quot;dataSource&quot; /&gt;
  &lt;/bean&gt;
  
  &lt;bean id=&quot;placeholderProperties&quot;
      class=&quot;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer&quot;&gt;
      &lt;property name=&quot;location&quot; value=&quot;classpath:batch.properties&quot; /&gt;
      &lt;property name=&quot;systemPropertiesModeName&quot; value=&quot;SYSTEM_PROPERTIES_MODE_OVERRIDE&quot; /&gt;
      &lt;property name=&quot;ignoreUnresolvablePlaceholders&quot; value=&quot;true&quot; /&gt;
      &lt;property name=&quot;order&quot; value=&quot;1&quot; /&gt;
  &lt;/bean&gt;
  </code></pre>