Announcement Announcement Module
Collapse
No announcement yet.
Newbie with Spring - No SqlMap specified Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Newbie with Spring - No SqlMap specified

    My application doesnīt seem to find a configuration file but I donīt know why.
    This is the exception:


    java.lang.IllegalArgumentException: No SqlMap specified
    at org.springframework.util.Assert.notNull(Assert.jav a:117)
    at org.springframework.orm.ibatis.SqlMapTemplate.exec ute(SqlMapTemplate.java:111)
    at org.springframework.orm.ibatis.SqlMapTemplate.exec uteQueryForObject(SqlMapTemplate.java:154)
    at com.arcor.concepto.spring.dao.SQLMapOrdersDao.getO rder(SQLMapOrdersDao.java:44)
    at com.arcor.concepto.spring.dao.ApplicationFacadeImp l.getOrder(ApplicationFacadeImpl.java:42)
    at com.arcor.concepto.spring.dao.test.main(test.java: 37)
    Exception in thread "main"


    Where should I place the files sql-map-config.xml, maps and dataAccessContextLocal, etc..

    Thanks in advance.

  • #2
    I have my sql-map-config.xml file in the WEB-INF directory, and my maps are scattered around the source tree. As long as the entries in the sql-map-config.xml file point to those maps, it should work fine.

    But judging from the exception that you're getting, it doesn't seem to be a problem locating these files, but rather a problem with the way that you're calling the functionality. How are you calling the SqlMapClientTemplate object?

    Geoff

    Comment


    • #3
      I'm calling the method like this:

      public Order getOrder(String OrderId) throws DataAccessException {
      return (Order) getSqlMapTemplate().executeQueryForObject("getOrde r", OrderId);
      }

      Comment


      • #4
        Hmmm... May I ask what version of Spring and iBatis you are using?

        Geoff

        Comment


        • #5
          You need to pass a SqlMap instance to the "sqlMap" property of your SqlMapTemplate - usually through the "sqlMap" property of your DAO deriving from SqlMapDaoSupport.

          The SqlMap instance is usally set up via Spring's SqlMapFactoryBean, which is responsible for loading the "sql-map-config.xml" file.

          Have a look at the JPetStore sample app (in the "samples/jpetstore" directory of the Spring distribution) for a working example.

          Juergen

          Comment


          • #6
            I'm using iBatis v 2.0.8.470 and Spring v 1.1.2

            Thanks for your replies

            Comment


            • #7
              Yep, make sure you look at the JPetStore example with the distribution. The other thing to note is that the example uses SqlMaps version 1.x.x. You're using version 2.0.8, which means that you need to use the getSqlMapClientTemplate method:

              Code:
              public Order getOrder(String OrderId) throws DataAccessException {
                  return (Order) getSqlMapClientTemplate().queryForObject("getOrder", OrderId);
              }
              See chapter 11.4.1 of the Spring reference manual for differences between the versions. You should probably also refer to the iBatis tutorial PDF.

              Geoff

              Comment

              Working...
              X