Results 1 to 7 of 7

Thread: Newbie with Spring - No SqlMap specified

  1. #1
    Join Date
    Dec 2004
    Posts
    8

    Default 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. #2
    Join Date
    Oct 2004
    Location
    Sydney, Australia
    Posts
    46

    Default

    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

  3. #3
    Join Date
    Dec 2004
    Posts
    8

    Default

    I'm calling the method like this:

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

  4. #4
    Join Date
    Oct 2004
    Location
    Sydney, Australia
    Posts
    46

    Default

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

    Geoff

  5. #5
    Join Date
    Aug 2004
    Location
    Linz, Austria
    Posts
    391

    Default

    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

  6. #6
    Join Date
    Dec 2004
    Posts
    8

    Default

    I'm using iBatis v 2.0.8.470 and Spring v 1.1.2

    Thanks for your replies

  7. #7
    Join Date
    Oct 2004
    Location
    Sydney, Australia
    Posts
    46

    Default

    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

Similar Threads

  1. Spring MVC Web Framework versus Struts
    By biguniverse in forum Web Flow
    Replies: 27
    Last Post: Aug 29th, 2012, 03:57 AM
  2. Newbie: moving from avalon to spring
    By Leonets in forum Container
    Replies: 5
    Last Post: Sep 2nd, 2005, 08:45 AM
  3. Newbie Question - The Ideal Spring Solution
    By conorp in forum Architecture
    Replies: 3
    Last Post: Aug 23rd, 2005, 03:22 AM
  4. A Spring Class Loader?
    By azzoti in forum Architecture
    Replies: 8
    Last Post: May 7th, 2005, 04:02 AM
  5. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •