Announcement Announcement Module
Collapse
No announcement yet.
Problem with Spring and iBatis Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with Spring and iBatis

    I get this error when I try to access the application in Tomcat:

    java.lang.IllegalArgumentException: No SqlMapClient specified
    org.springframework.util.Assert.notNull(Assert.jav a:91)
    org.springframework.orm.ibatis.SqlMapClientTemplat e.execute(SqlMapClientTemplate.java:139)
    org.springframework.orm.ibatis.SqlMapClientTemplat e.queryForObject(SqlMapClientTemplate.java:205)
    db.SqlMapUserDao.getUser(SqlMapUserDao.java:23)
    web.DemoController.handleRequest(DemoController.ja va:35)
    -----------------------
    In th demo-servlet.xml I have:

    <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClient FactoryBean">
    <property name="configLocation">
    <value>/WEB-INF/sql-map-config.xml</value>
    </property>
    </bean>

    <bean id="userDao" class="db.SqlMapUserDao">
    <property name="sqlMapClient"><ref bean="sqlMapClient"/></property>
    <property name="dataSource"><ref bean="dataSource"/></property>
    </bean>
    ---------------------------
    The sql-map-config.xml

    <sqlMapConfig>
    <sqlMap resource="User.xml"></sqlMap>
    </sqlMapConfig>
    ---------------------------
    And thr User.xml

    <sqlMap namespace="User">

    <select id="getUser" resultClass="db.User" parameterClass="java.lang.String">
    select
    userId,
    pwd,
    name,
    phone,
    mobil,
    email,
    created,
    changed,
    byUser
    from user
    where userId = #userId#
    </select>

    </sqlMap>
    ------------------------
    Here in SqlMapUserDoa is were it fails:

    public User getUser(String userId) throws DataAccessException {
    logger.info("UserId: " + userId);
    return (User) getSqlMapClientTemplate().queryForObject("User.get User", userId);
    }
    ------------------------
    What have I missed???

  • #2
    Now the problem i solved. I looked in the wrog direction. The error was in the demo-servlet.xml. I have forget to change the demoController bean to ref to the userDao bean.

    Comment

    Working...
    X