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 8607595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:23:52+00:00 2026-06-12T03:23:52+00:00

I am getting the following error: [C:\Users\Darin\apache-tomcat-6.0\webapps\crimeTrack\WEB-INF\classes\com\crimetrack\jdbc\JdbcCountryDAO.class]: Invocation of init method failed; nested exception

  • 0

I am getting the following error:

[C:\Users\Darin\apache-tomcat-6.0\webapps\crimeTrack\WEB-INF\classes\com\crimetrack\jdbc\JdbcCountryDAO.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: 'dataSource' or 'jdbcTemplate' is required
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
    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:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645)
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508)
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449)
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)
    at javax.servlet.GenericServlet.init(GenericServlet.java:212)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1206)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1026)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4421)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4734)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504)
    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1385)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:306)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
    at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1389)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1653)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1662)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1642)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: 'dataSource' or 'jdbcTemplate' is required

jdbcDAOCountry.java

@Repository
public class JdbcCountryDAO extends JdbcDaoSupport implements CountryDAO{

    private final Logger logger = Logger.getLogger(getClass());

    @Autowired
    private JdbcTemplate jdbcTemplate;  

    public List<Country> getCountryList() {
        int countryId = 6;
        String countryCode = "AI";
        logger.debug("In getCountryList()");
        String sql = "SELECT * FROM TBLCOUNTRY WHERE countryId = ? AND countryCode = ?";
        logger.debug("Executing getCountryList String "+sql);

        Object[] parameters = new Object[] {countryId, countryCode};

        logger.info(sql);

        //List<Country> countryList = getJdbcTemplate().query(sql,new CountryMapper());

        List<Country> countryList = getJdbcTemplate().query(sql, parameters,new CountryMapper());
        return countryList;
    }



    public void saveCountry(Country country) {
        logger.debug("In saveCountry");

        String sql= "INSERT INTO crimetrack.tblcountry (countryName, countryCode) " + 
                    "VALUES (:countryName, :countryCode)";

        logger.debug("Executing saveCountry String " + sql);
        int count = getJdbcTemplate().update(sql,new MapSqlParameterSource()

                .addValue("countryName", country.getCountryName())
                .addValue("countryCode", country.getCountryCode()));
        logger.debug(count +" Rows affected in tblCountry");


    }

    public void updateCountry(Country country) {
        logger.debug("In updateCountry");

        String sql= "UPDATE crimetrack.tblcountry SET countryName = :countryName, "+
                    "countryCode = :countryCode WHERE countryId = :countryId";

        logger.debug("Executing updateCountry String " + sql);
        int count = getJdbcTemplate().update(sql,new MapSqlParameterSource()
                .addValue("countryId",country.getCountryId())
                .addValue("countryName", country.getCountryName())
                .addValue("countryCode", country.getCountryCode()));
        logger.debug(count +" Rows affected in tblCountry");

    }

    public static class CountryMapper implements ParameterizedRowMapper<Country>{

         public Country mapRow(ResultSet rs, int rowNum) throws SQLException {
                Country country = new Country();
                country.setCountryCode(rs.getString("countryCode"));
                country.setCountryId(rs.getInt("countryId"));
                country.setCountryName(rs.getString("countryName"));
                return country;
            }       
    }

}

applicationContext.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:aop="http://www.springframework.org/schema/aop"
         xmlns:tx="http://www.springframework.org/schema/tx"
         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/aop 
           http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
           http://www.springframework.org/schema/tx 
           http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.0.xsd"> 



<!-- __________________________________________________________________________________________________ -->              

    <bean id="countryManager" class="com.crimetrack.service.CountryManager">
        <property name="countryDao" ref="countryDao"/>
    </bean>
    <bean id="countryDao" class="com.crimetrack.jdbc.JdbcCountryDAO">
        <property name="dataSource" ref="dataSource"/>
    </bean>
<!-- __________________________________________________________________________________________________ -->

    <bean id="authenticationManager" class="com.crimetrack.service.AuthenticationManager">
        <property name="loginDao" ref="loginDao" /> 
    </bean>    
    <bean id="loginDao" class="com.crimetrack.jdbc.JdbcLoginDAO">
        <property name="dataSource" ref="dataSource" />
    </bean>
<!-- __________________________________________________________________________________________________ -->  

    <bean id="divisionManager" class="com.crimetrack.service.DivisionManager">
        <property name="divisionDao" ref="divisionDao"/>
    </bean>    
    <bean id="divisionDao" class="com.crimetrack.jdbc.JdbcDivisionDAO">
        <property name="dataSource" ref="dataSource"/>
    </bean>

<!-- __________________________________________________________________________________________________ -->    

     <bean id="positionManager" class="com.crimetrack.service.PositionManager">
        <property name="positionDao" ref="positionDao"/>
    </bean>    
    <bean id="positionDao" class="com.crimetrack.jdbc.JdbcPositionDAO">
        <property name="dataSource" ref="dataSource" />
    </bean>    

<!-- __________________________________________________________________________________________________ -->    

    <bean id="genderManager" class="com.crimetrack.service.GenderManager">
        <property name="genderDao" ref="genderDao"/>
    </bean>

    <bean id="genderDao" class="com.crimetrack.jdbc.JdbcGenderDAO" >
        <property name="dataSource" ref="dataSource" />
    </bean>

<!-- __________________________________________________________________________________________________ --> 

    <bean id="officerRegistrationValidation" class="com.crimetrack.service.OfficerRegistrationValidation">

            <property name="validateUserNameManager" ref="validateUserNameManager"/>


    </bean>

    <bean id="validateUserNameManager" class="com.crimetrack.service.ValidateUserNameManager">
            <property name="officerDao" ref="officerDao"/>

    </bean>


    <bean id="officerDao" class="com.crimetrack.jdbc.JdbcOfficersDAO" >
            <property name="dataSource" ref="dataSource" />
    </bean>


<!-- __________________________________________________________________________________________________ --> 

    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource"><ref bean="dataSource" /></property>
    </bean>

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
            <property name="driverClassName" value="${jdbc.driverClassName}"/>
            <property name="url" value="${jdbc.url}"/>
            <property name="username" value="${jdbc.username}"/>
            <property name="password" value="${jdbc.password}"/>
    </bean>
<!-- __________________________________________________________________________________________________ -->    

    <bean id="propertyConfigurer" 
          class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:jdbc.properties</value>
            </list>
        </property>
    </bean>
<!-- __________________________________________________________________________________________________ -->    

    <bean id="transactionManager" 
          class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/>
    </bean>





  </beans>

servlet.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:mvc="http://www.springframework.org/schema/mvc"

       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
                           http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
                           http://www.springframework.org/schema/beans/spring-context-3.0.xsd">


<!-- __________________________________________________________________________________________________ -->    

     <!-- Supports annotations and allows the use of @Controller, @Required, @RequestMapping -->
    <context:annotation-config/>    

    <context:component-scan base-package="com.crimetrack.jdbc"/>
    <context:component-scan base-package="com.crimetrack.service"/>
    <context:component-scan base-package="com.crimetrack.web" />

    <mvc:annotation-driven />
  • 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-12T03:23:56+00:00Added an answer on June 12, 2026 at 3:23 am

    Ensure the applicationContext.xml has the bean dataSource defined.

    The DAO should pass a constructor-arg and not a property since dataSource is a constructor-arg.

    Annotate a constructor method and ensure it accepts a dataSource.

    The dataSource passes is the same one defined in the applicationContext.xml:

     <bean id="countryDao" class="com.crimetrack.jdbc.JdbcCountryDAO">
         <constructor-arg index="0" ref="dataSource"/>
     </bean>
    
    @Repository
    public class JdbcCountryDAO extends JdbcDaoSupport implements CountryDAO {
        private final Logger logger = Logger.getLogger(getClass());
    
        @Autowired
        JdbcCountryDAO(DataSource dataSource) {
            setDataSource(dataSource);
        }
    
        public List<Country> getCountryList() { 
        // ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On my site wemanageloans.com, many of the users are getting the following error when
I'm getting the following message in my users' crash logs: Dyld Error Message: Symbol
I am getting syntax error with the following statement REPLACE INTO users (screenname, token,
I am getting the following error from some users while performing a lightweight Core
I am getting the following error when trying to enumerate users in LDAP(Lightweight Directory
I'm getting the following error when trying to install 1.9.2 with rvm /Users/craigspaeth/.rvm/scripts/functions/utility: line
I'm getting the following error in my C++ program: 1> c:\users\thom\documents\cworkspace\barnaby\barnaby\timezone.cpp(14) : see reference
Need a second set of eyes. I am getting the following error: 1>c:\users\thom\documents\cworkspace\barnaby\barnaby\timezone.h(15): error
I'm getting the following error Could not load file or assembly 'file:///C:\Users\<project path>\bin\DotNetOpenAuth.dll' or
I'm getting the following error : /Users/nblavoie/Desktop/HotPie/HotPie/apps/authentication/routes.coffee:6 app.get('/login', function(req, res) { ^ ReferenceError: app

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.