Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8803749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:25:21+00:00 2026-06-14T01:25:21+00:00

I just wanted to add spring framework to my project, But when i try

  • 0

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,

    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

This is dao-def.xml

    <?xml version="1.0" encoding="UTF-8"?>
<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">

    <!-- All DAO bean definitions goes here -->
    <bean id="DAOFactory"
        class="com.tapgift.merchant.integration.db.dao.jdbc.JdbcDaoFactoryImpl" />

    <bean class="com.tapgift.merchant.integration.spring.DaoFactoryPostProcessor">
        <property name="daoFactory" ref="DAOFactory" />
    </bean>

     <bean id="merchantDao"
        class="com.tapgift.merchant.integration.db.dao.jdbc.JdbcMerchantDao">
        <property name="dataSource" ref="dataSource" />     
        <property name="queryFactory" ref="QueryFactory" />         
    </bean>

</beans>

This is application-context.xml

 <?xml version="1.0" encoding="UTF-8"?>
<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">

    <context:annotation-config />
    <context:component-scan base-package="com.tapgift.merchant" />

    <import resource="classpath:config/spring-integration.xml" />
    <import resource="classpath:config/dao-defs.xml" /> 
    <import resource="classpath:config/query-defs.xml" />   
    <import resource="classpath:config/spring-support.xml" />


</beans>

Finally this is web.xml

<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:config/application-context.xml
                /WEB-INF/spring/root-context.xml</param-value>
</context-param>

oops, almost missed the pom,

 <?xml version="1.0" encoding="UTF-8"?>
<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">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.tapgift</groupId>
    <artifactId>merchant</artifactId>
    <name>merchant-server</name>
    <packaging>war</packaging>
    <version>1.0.0-BUILD-SNAPSHOT</version>
    <properties>
        <java-version>1.7</java-version>
        <org.springframework-version>3.1.0.RELEASE</org.springframework-version>
        <org.aspectj-version>1.6.9</org.aspectj-version>
        <org.slf4j-version>1.5.10</org.slf4j-version>
    </properties>
    <dependencies>
        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework-version}</version>               
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>

        <dependency>
                   <groupId>commons-collections</groupId>
                   <artifactId>commons-collections</artifactId>
                   <version>3.2.1</version>
                   <scope>compile</scope>
            </dependency>
            <dependency>
                  <groupId>commons-lang</groupId>
                  <artifactId>commons-lang</artifactId>
                  <version>2.6</version>
                  <scope>compile</scope>
            </dependency>
            <dependency>
                 <groupId>commons-io</groupId>
                 <artifactId>commons-io</artifactId>
                 <version>2.0.1</version>
                 <scope>compile</scope>
            </dependency>
            <dependency>
                 <groupId>commons-dbcp</groupId>
                 <artifactId>commons-dbcp</artifactId>
                 <version>1.4</version>
                 <scope>compile</scope>
            </dependency>

        <!-- AspectJ -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>${org.aspectj-version}</version>
        </dependency>   

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${org.slf4j-version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.15</version>           
            <exclusions>
                <exclusion>
                    <groupId>javax.mail</groupId>
                    <artifactId>mail</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.jms</groupId>
                    <artifactId>jms</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jdmk</groupId>
                    <artifactId>jmxtools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jmx</groupId>
                    <artifactId>jmxri</artifactId>
                </exclusion>
            </exclusions>
            <scope>compile</scope>
        </dependency>

        <!-- @Inject -->
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>

        <!-- Servlet -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <!-- JSON view resolver -->
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.2</version>
        </dependency>

        <!-- Test -->
        <!-- <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </dependency>  -->       
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <additionalProjectnatures>
                        <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                    </additionalProjectnatures>
                    <additionalBuildcommands>
                        <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                    </additionalBuildcommands>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArgument>-Xlint:all</compilerArgument>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <configuration>
                    <mainClass>org.test.int1.Main</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

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.

Edit: Added DaoFactoryImpl

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 <code>CaseServiceImpl</code> is an implementation of the <tt>DaoFactory</tt> interface.
 */
public class JdbcDaoFactoryImpl implements DaoFactory, InitializingBean, ApplicationContextAware
{
    private ApplicationContext m_appCtx;
    private Map<String, EntityBaseDao<?>> m_daoMap = new HashMap<String, EntityBaseDao<?>>();

    /**
     * {@inheritDoc}.
     */
    @Override
    @SuppressWarnings("rawtypes")
    public void afterPropertiesSet() throws Exception
    {
        Map<String, BaseDao> 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 <T> T getEntityDao(Class<T> 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;
    }

}

Update 2
The problem seems to be creating the JdbbcDaoFactoryimpl instance, When i removed the
<bean id="DAOFactory" class="com.tapgift.merchant.integration.db.dao.jdbc.JdbcDaoFactoryImpl" /> 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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T01:25:23+00:00Added an answer on June 14, 2026 at 1:25 am

    Never mind, i was able to fix it, Slightly related to what Ajinkya showed.
    Problem was m_daoMap.put(((EntityBaseDao) dao).getEntityType().getName() on this code of JdbcDaoFactoryImpl. ((EntityBaseDao) dao).getEntityType() was not returning any value but null. I forgot to override / remove particular method of actual dao implementation class. Once i removed that method, i was able to deploy it without facing any problem.

    Thank you for your support anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

today I just opened my 1,5 month old project and wanted to add a
I just wanted to try Entity Framework to use it instead of NHibernate. I'm
I'm building a SpringMVC project for the first time and just wanted some feedback
There is error checking for a missing file or incorrectly typed file name...but for
i've been working on a project in java+maven+spring+hibernate and i wanted to automatically assign
I am just learning Spring3 Validation with Hibernate. I wanted to add Validation so
I don't know why this is erroring, but I'm just trying to add something
just wanted to ask where I define initial class properties? From other languages I
Just wanted to know how i would replace sitename.com with sitename2.com whenever a user
Just wanted to ask you about the drawbacks (I mean memory or reponse time)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.