Java Mailing List Archive

Home » user-cs.ibatis »

.net Apache



Replies: Find Java Web Hosting

Author LoginPost Reply
Hi, I'm using Spring.NET and am happy that I've got this working fine. I'm now trying to get iBatis to work. On the whole I think I've managed something that looks right in principal but I've hit a stumbling block with the following exception:
[NullReferenceException: Object reference not set to an instance of an object.]
   IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.ConfigureSqlMap() +1003
   IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Initialize() +5535
   IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean isCallFromDao) +384

- The error occurred while loading SqlMap.
- The error occurred in .]
   IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean isCallFromDao) +483
   IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument document, Boolean useConfigFileWatcher) +46
   IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Configure(String resource) +125

[ObjectDefinitionStoreException: Factory method 'IBatisNet.DataMapper.ISqlMapper Configure(System.String)' threw an Exception.]
   Spring.Objects.Factory.Support.SimpleInstantiationStrategy.Instantiate(RootObjectDefinition definition, String name, IObjectFactory factory, MethodInfo factoryMethod, Object[] arguments) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Objects\Factory\Support\SimpleInstantiationStrategy.cs:216
   Spring.Objects.Factory.Support.ConstructorResolver.InstantiateUsingFactoryMethod(String name, RootObjectDefinition definition, Object[] arguments) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Objects\Factory\Support\ConstructorResolver.cs:339
   Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.InstantiateUsingFactoryMethod(String name, RootObjectDefinition definition, Object[] arguments) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Objects\Factory\Support\AbstractAutowireCapableObjectFactory.cs:1062
   Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.CreateObjectInstance(String objectName, RootObjectDefinition objectDefinition, Object[] arguments) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Objects\Factory\Support\AbstractAutowireCapableObjectFactory.cs:944
   Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.InstantiateObject(String name, RootObjectDefinition definition, Object[] arguments, Boolean allowEagerCaching, Boolean suppressConfigure) in l:\projects\spring-net\trunk\src\Spring\Spring.Core\Objects\Factory\Support\AbstractAutowireCapableObjectFactory.cs:862

[ObjectCreationException: Error creating object with name 'sqlMapper' defined in 'file [C:\dotNet\SpringMVCExample\ExampleApplication\Config\Controllers.xml] line 12' : Initialization of object failed : Factory method 'IBatisNet.DataMapper.ISqlMapper Configure(System.String)' threw an Exception.]


I have a User.xml sqlMap:
<?xml version="1.0" encoding="utf-8" ?>
    <typeAlias alias="User" assembly="ExampleApplication" type="ExampleApplication.Models.Entity.User" />

    <resultMap id="SelectAllResult" class="User">
        <result property="Id"         column="id" />
        <result property="Name"       column="name" />
        <result property="CreatedBy"  column="createdBy" />
        <result property="ModfiiedBy" column="modifiedBy" />
        <result property="CreatedOn"  column="createdOn" />
        <result property="ModifiedOn" column="modifiedOn" />

    <select id="SelectAll" resultMap="SelectAllResult">
        select id,
          from USERS
As well as the UserDao and iBatisDao object:
    public class IbatisDao
        private ISqlMapper sqlMap;

        public ISqlMapper SqlMap
            get { return sqlMap; }
            set { sqlMap = value; }

    public class UserDao : IbatisDao, IUserDao 
        public List<User> selectAll()
            return (List<User>)SqlMap.QueryForList("SelectAll",null);

Now I'm trying to get Spring to create the ISqlMapper object and this is where I'm hitting the exception: This is the Controllers.xml file mentioned in the error trace.
    <object id="builder"
                type="IBatisNet.DataMapper.Configuration.DomSqlMapBuilder, IBatisNet.DataMapper"
    <object id="sqlMapper"
            type="IBatisNet.DataMapper.ISqlMapper, IBatisNet.DataMapper"
        <constructor-arg value="Config/sqlMap.config.xml"/>        

I want the sqlMap.config file in the Config directory hence the call to Configure instead of Instance(): If I place the sqlMap.config file in the root of the project and use the Instance() method I get exactly the same error. If I remove the sqlMapper object from the container everything works well as expected without the error.
N.B. If you don't know spring then I'm basically trying to create an IBatisNet.DataMapper.ISqlMapper object by creating a builder object and using it to call Configure passing in the config file location Config/sqlMap.config.xml.
For completeness here is said file which does get parsed as if I mess about with it I can produce errors like file not found etc.
<?xml version="1.0" encoding="utf-8"?>
xmlns:xsi="" >

        <setting useStatementNamespaces="false"/>
        <setting cacheModelsEnabled="false"/>

    <providers resource="Config/providers.config.xml"/>
        <provider name="sqlServer1.1"/>                        
        <dataSource name="Scratch"
          connectionString="Data Source=XXXX;Initial Catalog=Scratch;User ID=XXXX;Password=XXXX;database=XXXX"/>

        <sqlMap resource="Models/Dao/ibatis/User.xml"/>

Let me know if there's something relevant I've failed to post. I presume that there is a null reference somewhere but I don't know how to find out what is missing. any pointers would be greatfully received.

View this message in context: .net Apache
Sent from the iBATIS - User - Cs mailing list archive at
©2008 - Jax Systems, LLC, U.S.A.