Wednesday, August 7, 2013

java.lang.IllegalArgumentException: Mapped Statements collection does not contain value - iBatis

java.lang.IllegalArgumentException: Mapped Statements collection does not contain value - iBatis

Sometimes we will be receiving the following exception when executing the iBatis queries.

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.tr.spm.app.persistence.mybatis.clientmgmt.ClientManagmentMapper.getTntGrpid
        at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:178)
Caused by: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.tr.spm.app.persistence.mybatis.clientmgmt.ClientManagmentMapper.getTnt
        at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:775)

The issue is due to server could not able to locate the mapper xml file.

Approaches to fix the issue

This might be due to multiple reason, the following are the some of the ways the issue can be fixed.

1. Make sure the mapper xml file is in the same location as the mapper interface



2. Make sure the mapper interface java class name and the mapper xml file is same.

3. When u are using maven make sure the xml files are getting copied when packaging. Make sure we have added the below resource entry under resources section in pom.xml

         <resource>
                <directory>src/main/java</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/*.xml</include>
                </includes>
          </resource>



6 comments:

  1. Thank's man this treally helped me is there any way to change these xml files from here and place them in resources folder

    ReplyDelete
  2. and one more thing for other users is that please remember that these xml file names are case sensitive

    ReplyDelete
  3. Thanks a lot. I also misplaced the mapper xml file in java/test/resources folder ....

    ReplyDelete