ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Smiley <ssmiley...@yahoo.com>
Subject Re: NullReferenceException during initialization
Date Wed, 01 Mar 2006 16:32:25 GMT
I was able to track down the cause of this problem.  It turned out I missed the xmlns attributes
in my sqlMap XML file.


Shawn Smiley <ssmiley483@yahoo.com> wrote: I've just started a new project that has
some very simple data access requirements.  I started off by copying my iBatis configuration
files from another project that was working into the new project.

Unforutnately I'm getting the following error and just can't put my finger on what is causing

UnitTests.DataTests.Find : System.TypeInitializationException : The type initializer for "Data.Dal.PaymentLog"
threw an exception.
  ----> IBatisNet.Common.Exceptions.ConfigurationException : 
- The error occurred while loading SqlMap.
- The error occurred in <sqlMap resource="${root}DataMaps/PaymentLog.xml" xmlns="http://ibatis.apache.org/dataMapper"
  ----> System.NullReferenceException : Object reference not set to an instance of an object.

Here is the stack trace:
   at Data.Dal.PaymentLog.Find()
   at UnitTests.DataTests.Find() in  C:\VSProjects\ADDSIntegration\trunk\ADDSintegrationSolution\UnitTests\DataTests.cs:line
   at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument document, DataSource
dataSource, Boolean useConfigFileWatcher, Boolean isCallFromDao)
   at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.ConfigureAndWatch(String resource,
ConfigureHandler configureDelegate)
   at IBatisNet.DataMapper.Mapper.InitMapper()
   at IBatisNet.DataMapper.Mapper.Instance()
   at Data.Dal.PaymentLog..cctor() in c:\vsprojects\addsintegration\trunk\addsintegrationsolution\data\dal\paymentlog.cs:line
   at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.ConfigureSqlMap()
   at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Initialize()
   at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocumen  t  document, DataSource
dataSource, Boolean useConfigFileWatcher, Boolean isCallFromDao)

The database being connected to is MySQL 5 using the .net Connector 1.0.7 (I've updated the
properties.config with the new connector version number).

I've also stripped down my DataMap file to just including the property/field mappings and
a single simple select with no parameters.  

Any thoughts on what else I should check?  My full config files are listed below.

<?xml version="1.0" encoding="utf-8" ?> 
    <add key="provider" value="MySql" />
    <add key="connectionString" value="Persist Security Info=False;Host=localhost;Protocol=tcp;Initial
Catalog=AddsAudit;User Id=AddsAudit;password=password;" />
    <add key="root" value="" />

<?xml version="1.0"  encoding="utf-8"?>
<sqlMapConfig xmlns="http://ibatis.apache.org/dataMapper" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
    <properties resource="properties.config"/>
        <setting useStatementNamespaces="false"/>
        <setting cacheModelsEnabled="true"/>
        <provider name="${provider}"/>
        <dataSource name="ADDSLocalDb"  connectionString="${connectionString}"/>

        <typeAlias alias="PaymentLog" type="Data.Dal.PaymentLog, Data" />

        <sqlMap resource="${root}DataMaps/PaymentLog.xml" />

<?xml version="1.0" encoding="utf-8" ?> 
<sqlMap namespace="DAL">
        <resultMap id="PaymentLogMap" class="PaymentLog">
            <result property="AddsConfirmationNumber" column="AddsConfirmationNumber" />
            <result property="Amount" column="Amount" />
            <result property="EntryDateTime" column="EntryDateTime" />
            <result property="FullAccountNumber" column="FullAccountNumber"  />
            <result property="Id" column="Id" />
            <result property="PaymentServiceConfirmationNumber" column="PaymentServiceConfirmationNumber"
            <result property="ShortAccountNumber" column="ShortAccountNumber" />
        <select id="SelectPaymentLog" resultMap="PaymentLogMap">
            SELECT * 
            FROM PaymentLogs


Yahoo! Mail
 Bring photos to life! New PhotoMail  makes sharing a breeze.  

Yahoo! Mail
Bring photos to life! New PhotoMail  makes sharing a breeze. 
View raw message