title: Spring deployment in jboss error
body: <p>I just wanted to add spring framework to my project, But when i try to deploy my war file in jboss 6.1.0 Final, it gives a error. I get following error,</p>
  
  <pre><code>    11:01:46,556 INFO  [STDOUT] ERROR: org.springframework.web.context.ContextLoader - Context initializ
  ation failed
  11:01:46,557 INFO  [STDOUT] org.springframework.beans.factory.BeanCreationException: Error creating
  bean with name 'com.tapgift.merchant.integration.spring.DaoFactoryPostProcessor#0' defined in class
  path resource [config/dao-defs.xml]: Cannot resolve reference to bean 'DAOFactory' while setting bea
  n property 'daoFactory'; nested exception is org.springframework.beans.factory.BeanCreationException
  : Error creating bean with name 'DAOFactory' defined in class path resource [config/dao-defs.xml]: I
  nvocation of init method failed; nested exception is java.lang.NullPointerException
  </code></pre>
  
  <p>This is dao-def.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"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
             http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"&gt;
  
      &lt;!-- All DAO bean definitions goes here --&gt;
      &lt;bean id="DAOFactory"
          class="com.tapgift.merchant.integration.db.dao.jdbc.JdbcDaoFactoryImpl" /&gt;
  
      &lt;bean class="com.tapgift.merchant.integration.spring.DaoFactoryPostProcessor"&gt;
          &lt;property name="daoFactory" ref="DAOFactory" /&gt;
      &lt;/bean&gt;
  
       &lt;bean id="merchantDao"
          class="com.tapgift.merchant.integration.db.dao.jdbc.JdbcMerchantDao"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;     
          &lt;property name="queryFactory" ref="QueryFactory" /&gt;         
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>This is application-context.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.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"&gt;
  
      &lt;context:annotation-config /&gt;
      &lt;context:component-scan base-package="com.tapgift.merchant" /&gt;
  
      &lt;import resource="classpath:config/spring-integration.xml" /&gt;
      &lt;import resource="classpath:config/dao-defs.xml" /&gt; 
      &lt;import resource="classpath:config/query-defs.xml" /&gt;   
      &lt;import resource="classpath:config/spring-support.xml" /&gt;
  
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>Finally this is web.xml</p>
  
  <pre><code>&lt;!-- The definition of the Root Spring Container shared by all Servlets and Filters --&gt;
  &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;classpath:config/application-context.xml
                  /WEB-INF/spring/root-context.xml&lt;/param-value&gt;
  &lt;/context-param&gt;
  </code></pre>
  
  <p>oops, almost missed the pom,</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;com.tapgift&lt;/groupId&gt;
      &lt;artifactId&gt;merchant&lt;/artifactId&gt;
      &lt;name&gt;merchant-server&lt;/name&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;version&gt;1.0.0-BUILD-SNAPSHOT&lt;/version&gt;
      &lt;properties&gt;
          &lt;java-version&gt;1.7&lt;/java-version&gt;
          &lt;org.springframework-version&gt;3.1.0.RELEASE&lt;/org.springframework-version&gt;
          &lt;org.aspectj-version&gt;1.6.9&lt;/org.aspectj-version&gt;
          &lt;org.slf4j-version&gt;1.5.10&lt;/org.slf4j-version&gt;
      &lt;/properties&gt;
      &lt;dependencies&gt;
          &lt;!-- Spring --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework-version}&lt;/version&gt;               
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework-version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework-version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework-version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
                     &lt;groupId&gt;commons-collections&lt;/groupId&gt;
                     &lt;artifactId&gt;commons-collections&lt;/artifactId&gt;
                     &lt;version&gt;3.2.1&lt;/version&gt;
                     &lt;scope&gt;compile&lt;/scope&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                    &lt;groupId&gt;commons-lang&lt;/groupId&gt;
                    &lt;artifactId&gt;commons-lang&lt;/artifactId&gt;
                    &lt;version&gt;2.6&lt;/version&gt;
                    &lt;scope&gt;compile&lt;/scope&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                   &lt;groupId&gt;commons-io&lt;/groupId&gt;
                   &lt;artifactId&gt;commons-io&lt;/artifactId&gt;
                   &lt;version&gt;2.0.1&lt;/version&gt;
                   &lt;scope&gt;compile&lt;/scope&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                   &lt;groupId&gt;commons-dbcp&lt;/groupId&gt;
                   &lt;artifactId&gt;commons-dbcp&lt;/artifactId&gt;
                   &lt;version&gt;1.4&lt;/version&gt;
                   &lt;scope&gt;compile&lt;/scope&gt;
              &lt;/dependency&gt;
  
          &lt;!-- AspectJ --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.aspectj&lt;/groupId&gt;
              &lt;artifactId&gt;aspectjrt&lt;/artifactId&gt;
              &lt;version&gt;${org.aspectj-version}&lt;/version&gt;
          &lt;/dependency&gt;   
  
          &lt;!-- Logging --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
              &lt;version&gt;${org.slf4j-version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;jcl-over-slf4j&lt;/artifactId&gt;
              &lt;version&gt;${org.slf4j-version}&lt;/version&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
              &lt;version&gt;${org.slf4j-version}&lt;/version&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;log4j&lt;/groupId&gt;
              &lt;artifactId&gt;log4j&lt;/artifactId&gt;
              &lt;version&gt;1.2.15&lt;/version&gt;           
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;javax.mail&lt;/groupId&gt;
                      &lt;artifactId&gt;mail&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;javax.jms&lt;/groupId&gt;
                      &lt;artifactId&gt;jms&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;com.sun.jdmk&lt;/groupId&gt;
                      &lt;artifactId&gt;jmxtools&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;com.sun.jmx&lt;/groupId&gt;
                      &lt;artifactId&gt;jmxri&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;!-- @Inject --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.inject&lt;/groupId&gt;
              &lt;artifactId&gt;javax.inject&lt;/artifactId&gt;
              &lt;version&gt;1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- Servlet --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
              &lt;version&gt;2.5&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
              &lt;artifactId&gt;jsp-api&lt;/artifactId&gt;
              &lt;version&gt;2.1&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;jstl&lt;/artifactId&gt;
              &lt;version&gt;1.2&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- JSON view resolver --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-mapper-asl&lt;/artifactId&gt;
              &lt;version&gt;1.9.2&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- Test --&gt;
          &lt;!-- &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;4.7&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;  --&gt;       
      &lt;/dependencies&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-eclipse-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.9&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;additionalProjectnatures&gt;
                          &lt;projectnature&gt;org.springframework.ide.eclipse.core.springnature&lt;/projectnature&gt;
                      &lt;/additionalProjectnatures&gt;
                      &lt;additionalBuildcommands&gt;
                          &lt;buildcommand&gt;org.springframework.ide.eclipse.core.springbuilder&lt;/buildcommand&gt;
                      &lt;/additionalBuildcommands&gt;
                      &lt;downloadSources&gt;true&lt;/downloadSources&gt;
                      &lt;downloadJavadocs&gt;true&lt;/downloadJavadocs&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.3.2&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.6&lt;/source&gt;
                      &lt;target&gt;1.6&lt;/target&gt;
                      &lt;compilerArgument&gt;-Xlint:all&lt;/compilerArgument&gt;
                      &lt;showWarnings&gt;true&lt;/showWarnings&gt;
                      &lt;showDeprecation&gt;true&lt;/showDeprecation&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;1.2.1&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;mainClass&gt;org.test.int1.Main&lt;/mainClass&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>I can see all the files compiled and assembled to the war file. Appreciate, if a spring guru can point me the reason for this deployment error.  </p>
  
  <p>Edit: Added DaoFactoryImpl</p>
  
  <pre><code>package com.tapgift.merchant.integration.db.dao.jdbc;
  
  import java.lang.reflect.ParameterizedType;
  import java.util.HashMap;
  import java.util.Map;
  
  import org.springframework.beans.BeansException;
  import org.springframework.beans.factory.InitializingBean;
  import org.springframework.context.ApplicationContext;
  import org.springframework.context.ApplicationContextAware;
  
  import com.tapgift.merchant.integration.db.dao.BaseDao;
  import com.tapgift.merchant.integration.db.dao.DaoFactory;
  import com.tapgift.merchant.integration.db.dao.EntityBaseDao;
  
  /**
   * Class &lt;code&gt;CaseServiceImpl&lt;/code&gt; is an implementation of the &lt;tt&gt;DaoFactory&lt;/tt&gt; interface.
   */
  public class JdbcDaoFactoryImpl implements DaoFactory, InitializingBean, ApplicationContextAware
  {
      private ApplicationContext m_appCtx;
      private Map&lt;String, EntityBaseDao&lt;?&gt;&gt; m_daoMap = new HashMap&lt;String, EntityBaseDao&lt;?&gt;&gt;();
  
      /**
       * {@inheritDoc}.
       */
      @Override
      @SuppressWarnings("rawtypes")
      public void afterPropertiesSet() throws Exception
      {
          Map&lt;String, BaseDao&gt; beanMap = m_appCtx.getBeansOfType(BaseDao.class);
          for (final BaseDao dao : beanMap.values())
          {
              m_daoMap.put(((EntityBaseDao) dao).getEntityType().getName(), (EntityBaseDao) dao);
          }
      }
  
      /**
       * {@inheritDoc}.
       */
      @Override
      public BaseDao getDao(String name)
      {
          return this.m_daoMap.get(name);
      }
  
      /**
       * {@inheritDoc}.
       */
      @Override
      public &lt;T&gt; T getEntityDao(Class&lt;T&gt; clazz)
      {
          String entityName = ((Class) ((ParameterizedType) clazz.getGenericInterfaces()[0]).getActualTypeArguments()[0])
              .getSimpleName().toUpperCase();
          return clazz.cast(this.m_daoMap.get(entityName));
      }
  
      /**
       * Set method for m_appCtx
       */
      @Override
      public void setApplicationContext(ApplicationContext appCtx) throws BeansException
      {
          this.m_appCtx = appCtx;
      }
  
  }
  </code></pre>
  
  <p><strong>Update 2</strong>
  The problem seems to be creating the JdbbcDaoFactoryimpl instance, When i removed the
  <code>&lt;bean id="DAOFactory" class="com.tapgift.merchant.integration.db.dao.jdbc.JdbcDaoFactoryImpl" /&gt;</code> with its dependencies, i can deploy it without any problem. I checked the war file and all spring jars are belongs to same version. Need  a help desperately.</p>