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

  • More - Property 'sqlMapClient' is required

    I'm trying to get ibatis setup with spring and hit a very preliminary error that I can't figure out. I see other people have posted about this problem but I'm not able to successfully troubleshoot. Maybe some fresh eyes can help me out?

    I'm using spring mvc 2.5.6 and ibatis 2.3.4.76. I'm also generating all of the ibatis and DAO code with the ibator.

    The error I am getting is the following:
    Property 'sqlMapClient' is required

    Here's my config files:

    applicationContext.xml
    Code:
    <?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-2.0.xsd">
    
    		<!--  Setup the data source -->
    	<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/xxx?autoReconnect=true" />
    		<property name="username" value="xxx" />
    		<property name="password" value="xxx" />
    	</bean>
    	
    	<!-- Setup the iBatis SQL Map -->
    	<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
    		<property name="configLocation" value="classpath:SqlMapConfig.xml"/>
    		<property name="dataSource" ref="dataSource" />
    	</bean>
    
    	<bean id="userDAO" class="com.purpleherring.db.dao.UserDAOImpl">
    		<property name="sqlMapClient" ref="sqlMapClient"/>
    	</bean>
    
    </beans>
    SqlMapConfig.xml
    Code:
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-config-2.dtd" >
    <sqlMapConfig >
      <!--
        This file is generated by Apache iBATIS ibator.
        This file is the shell of an SqlMapConfig file - in many cases you will need to add
          to this file before it is usable by iBATIS.
        This file was generated on Wed Jul 08 12:56:57 EDT 2009.
      -->
      <settings useStatementNamespaces="true" />
      <sqlMap resource="com/purpleherring/db/sql/user_SqlMap.xml" />
    </sqlMapConfig>
    dispatcher-servlet.xml
    Code:
    <?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-2.5.xsd">
    
        <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
            <property name="prefix" value="/pages/"></property>
            <property name="suffix" value=".jsp"></property>        
        </bean>
    
    	<bean id="beanNameUrlMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
    
    	<bean id="loginMgr" class="com.purpleherring.game.service.LoginMgrImpl">
            <property name="userDAO">
                <bean class="com.purpleherring.db.dao.UserDAOImpl"/>
            </property>
    	</bean>
    </beans>

  • #2
    You are redining your UserDao, you have 2 instances, in your servlet.xml reference the one from the applicationContext.xml...

    Comment


    • #3
      Thanks, it was actually an injection issue. That worked!

      Comment


      • #4
        No it wasn't... YOu now have 2 dao's 1 useless instance and 1 defined as an inner bean. Which imho is a waste of resources...

        Comment

        Working...
        X