ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCurrey <mmccur...@gmail.com>
Subject Re: .net Apache
Date Tue, 17 Nov 2009 18:46:09 GMT
To be honest, I haven't used the Spring.NET configuration, I'm using the
Castle project (roughly the same thing).  Somebody else on the forum might
have used it or you can also post to the Spring group

On Tue, Nov 17, 2009 at 8:56 AM, puow <dc@dezmond.co.uk> wrote:

> * 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
>
> [ConfigurationException:
> - 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" ?>
> <sqlMap>
>     <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" />
>     </resultMap>
>
>     <select id="SelectAll" resultMap="SelectAllResult">
>         select id,
>                name,
>                createdBy,
>                modifiedBy,
>                createdOn,
>                modifiedOn
>           from USERS
>     </select>
> </sqlMap>
>
> *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"
>                 singleton="true"/>
>
>     <object id="sqlMapper"
>             type="IBatisNet.DataMapper.ISqlMapper, IBatisNet.DataMapper"
>             factory-method="Configure"
>             factory-object="builder"
>             singleton="true">
>         <constructor-arg value="Config/sqlMap.config.xml"/>
>     </object>
>
>
> * 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"?>
> <sqlMapConfig
> xmlns="http://ibatis.apache.org/dataMapper"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
>
>     <settings>
>         <setting useStatementNamespaces="false"/>
>         <setting cacheModelsEnabled="false"/>
>     </settings>
>
>
>     <providers resource="Config/providers.config.xml"/>
>
>     <database>
>         <provider name="sqlServer1.1"/>
>         <dataSource name="Scratch"
>           connectionString="Data Source=XXXX;Initial Catalog=Scratch;User ID=XXXX;Password=XXXX;database=XXXX"/>
>     </database>
>
>     <sqlMaps>
>         <sqlMap resource="Models/Dao/ibatis/User.xml"/>
>     </sqlMaps>
>
> </sqlMapConfig>
>
> * 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<http://old.nabble.com/.net-Apache-tp26392377p26392377.html>
> Sent from the iBATIS - User - Cs mailing list archive<http://old.nabble.com/iBATIS---User---Cs-f369.html>at
Nabble.com.
>



-- 
Michael J. McCurrey
Read with me at http://www.mccurrey.com
http://chaoticmindramblings.blogspot.com/

Mime
View raw message