Announcement Announcement Module
No announcement yet.
sqlMapClient is required?? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • sqlMapClient is required??

    I'm getting the following error:

    18:00:18,417 ERROR [ContextLoader] Context initialization failed
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'objectidsDAO' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: sqlMapClient is required
    Caused by:
    java.lang.IllegalArgumentException: sqlMapClient is required

    I have a sqlMapConfig.xml. What else do I need?

  • #2
    Are you using trying to use Ibatis?

    If you are here is one possible way to do it...

     <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
            <property name="driverClassName" value="com.mysql.jdbc.Driver" />
            <property name="url" value="jdbc:mysql://localhost:3306/testing" />
            <property name="username" value="someUsername" />
            <property name="password" value="somePassword" />
         <!-- SqlMap setup for iBATIS Database Layer -->
        <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
            <property name="configLocation" value="WEB-INF/IbatisSqlMap-Config.xml" />
            <property name="dataSource" ref="dataSource" />       
        <bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
             <property name="sqlMapClient" ref="sqlMapClient" />
    and then make sure the sqlMapClientTemplate is being injected into your DAO objects...

    public class SomeIbatisDao extends SqlMapClientDaoSupport implements SomeDao
        public List someMethodUsingIbatis(int id)
            getSqlMapClientTemplate().queryForList("queryNameInIbatisSqlXmlFile", id);
        public void setSqlMapClientTemplate(sqlMapClientTemplate   sqlMapClientTemplate)
            this.sqlMapClientTemplate = sqlMapClientTemplate;
        private SqlMapClientTemplate sqlMapClientTemplate;


    • #3
      Yes, that is a good way of putting it, 'I am trying to use iBATIS'.

      I have an abatorConfig.xml file which includes :

      <javaModelGenerator targetPackage="com.base.domain.model" targetProject="JPS"/>
      <sqlMapGenerator targetPackage="com.base.dao.ibatis" targetProject="JPS"/>
      <daoGenerator type="SPRING" targetPackage="com.base.dao" targetProject="JPS"/>

      I thought this was how Spring would be aware of the DAOs.

      I also have a persistance.ibatis.xml where my sqlmap and DAOs are defined:

      <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClient FactoryBean">
      <property name="configLocation" value="classpath:sqlMapConfig.xml"/>
      <property name="dataSource" ref="dataSource"/>

      <bean id="objectidsDAO" class="com.base.dao.ObjectidsDAOImpl">
      <property name="sqlMapClient" ref="sqlMapClient"/>

      but it seems the WebApp can't find this file or is not using it.

      I also have a sqlMapConfig.xml file that lists the sqlmap files:

      <sqlMap resource="com/base/dao/ibatis/OBJECTIDS_SqlMap.xml"/>

      I don't have a dao.xml like an iBATIS document suggests.
      Last edited by Edwin A; Feb 5th, 2009, 11:08 AM.


      • #4
        Sorry, I haven't tried using it with Abator yet, I am not familiar with how you are suppose to set that part up...

        As long as you have a datasource configured through spring, you shouldn't have to worry about the ibatis dao.xml, I think that is if you are trying to use Ibatis without Spring.

        From your original error message, it looks like your "objectidsDAO" is somehow not getting the reference of sqlMapClient. Maybe the "sqlMapClient" bean isn't able to be created either? Are there more error messages than just the first one posted? I would also suggest maybe turning your logging level to DEBUG level, to get more of an idea of what is going on.

        Also try to use the Code tags, for listing code, it makes things a little easier to read.
        Last edited by joshr; Feb 5th, 2009, 02:57 PM.