title: Error parsing Mapper XML. Cause: java.lang.NullPointerException
body: <p>I've been trying to convert from mybatis2 to mybatis3 and its giving me all sorts of problems. From the stacktrace im getting a <code>Error Parsing Mapper XML</code> for <code>sqlMapConfig.xml</code> which I take it means there is something wrong there however I cannot see it. I would greatly appreciate any help.</p>
  
  <p>sqlMapConfig.xml
      </p>
  
  <pre><code>&lt;!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"&gt;
  
  &lt;configuration&gt;
      &lt;settings&gt; 
          &lt;setting name="cacheModelsEnabled" value="true" /&gt;
          &lt;setting name="enhancementEnabled" value="true"/&gt;
          &lt;setting name="lazyLoadingEnabled" value="true"/&gt; 
          &lt;setting name="maxRequests" value="128"/&gt; 
          &lt;setting name="maxSessions" value="10"/&gt;
          &lt;setting name="maxTransactions" value="5"/&gt; 
          &lt;setting name="defaultStatementTimeout" value="0"/&gt; 
          &lt;setting name="statementCachingEnabled" value="true"/&gt;
          &lt;setting name="classInfoCacheEnabled" value="true"/&gt; 
      &lt;/settings&gt;
  
      &lt;mappers&gt;
          &lt;mapper resource="com/fidelity/cmplnr/datasource/search_sql.xml"/&gt;
      &lt;/mappers&gt;
  
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>beans.xml</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:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="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"&gt;
      &lt;context:annotation-config /&gt;
  
      &lt;bean id="propertyConfigurer"
          class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
          &lt;property name="locations"&gt;
              &lt;list&gt;
                  &lt;value&gt;classpath:jdbc.properties&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="dataSource"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
          &lt;property name="url" value="${jdbc.url}" /&gt;
          &lt;property name="driverClassName" value="${jdbc.driver}" /&gt;
          &lt;property name="username" value="${jdbc.username}" /&gt;
          &lt;property name="password" value="${jdbc.password}" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="sqlMapClient" class="org.mybatis.spring.SqlSessionFactoryBean"&gt;
          &lt;property name="mapperLocations" value="classpath:sqlMapConfig.xml" /&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="transactionManager"
          class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt;
          &lt;property name="dataSource"&gt;
              &lt;ref bean="dataSource" /&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
  
      &lt;bean id="ServiceImpl" class="com.fidelity.cmplnr.integration.ServiceImpl"&gt;
          &lt;property name="sqlMapClient" ref="sqlMapClient" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="AuthenticationServiceImpl" class="com.fidelity.cmplnr.core.AuthenticationServiceImpl"&gt;
          &lt;property name="sqlMapClient" ref="sqlMapClient" /&gt;
      &lt;/bean&gt;
  
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>search_sql.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"&gt; 
  
  &lt;mapper namespace="searchService"&gt;
  
      &lt;resultMap id="getEmpScrCombinedMap" type="com.fidelity.cmplnr.core.EMP_SCR"&gt;
          &lt;result property="name" column="PERSON_FULL_NAME" /&gt;
          &lt;result property="Payroll_ID" column="ASSIGNMENT_NUMBER" /&gt;
          &lt;result property="corp_id" column="CORP_ID" /&gt;
          &lt;result property="Manager" column="SUPERVISOR_NAME" /&gt;
          &lt;result property="cost_center" column="SCOPING_6" /&gt;
      &lt;/resultMap&gt;
      &lt;select id="getEmpScrCombined" resultMap="getEmpScrCombinedMap" parameterType="java.util.Map"&gt;
          SELECT person_full_name, assignment_number, corp_id, supervisor_name, scoping_6
  
          FROM $table_name$
  
          WHERE plan_id = $plan_id$
  
           &lt;if test= "$table_name$ = SSO_CMPLNR_COMBINED"&gt;
  
              &lt;dynamic prepend="AND"&gt;
                  &lt;isNotEqual prepend="AND" property="emp_lname" compareValue="0"&gt;
  
                      LOWER(last_name) like '$emp_lname$&amp;#37;'
  
                  &lt;/isNotEqual&gt;
  
                  &lt;isNotEqual prepend="AND" property="emp_fname" compareValue="0"&gt;
  
                      LOWER(first_name) like '$emp_fname$&amp;#37;'
  
                  &lt;/isNotEqual&gt;
  
                  &lt;isNotEqual prepend="AND" property="payId" compareValue="0"&gt;
  
                      LOWER(assignment_number) like '$payId$&amp;#37;'
  
                  &lt;/isNotEqual&gt;
  
                  &lt;isNotEqual prepend="AND" property="corp_id" compareValue="0"&gt;
  
                      LOWER(corp_id) like '$corp_id$&amp;#37;'
  
                  &lt;/isNotEqual&gt;
  
                  &lt;isNotEqual prepend="AND" property="manager_lname" compareValue="0"&gt;
  
                      LOWER(supervisor_name) like '$manager_lname$&amp;#37;'
  
                  &lt;/isNotEqual&gt;
  
                  &lt;isNotEqual prepend="AND" property="manager_fname" compareValue="0"&gt;
  
                      LOWER(supervisor_name) like '%, $manager_fname$&amp;#37;'
  
                  &lt;/isNotEqual&gt;
  
              &lt;/dynamic&gt;
  
           &lt;/if&gt;
  
  
      &lt;/select&gt;
  
  &lt;/mapper&gt;
  </code></pre>
  
  <p>stacktrace</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlMapClient' defined in class path resource [beans.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'class path resource [sqlMapConfig.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.NullPointerException
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1412)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:546)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:872)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
      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 com.fidelity.cmplnr.test.TestService.setUp(TestService.java:17)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
  Caused by: org.springframework.core.NestedIOException: Failed to parse mapping resource: 'class path resource [sqlMapConfig.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.NullPointerException
      at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:466)
      at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:340)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1469)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)
      ... 34 more
  Caused by: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.NullPointerException
      at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:117)
      at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:89)
      at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:464)
      ... 37 more
  Caused by: java.lang.NullPointerException
      at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:105)
      ... 39 more
  </code></pre>