You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Morten Schmidt <sc...@knowledgelab.sdu.dk> on 2005/06/08 13:25:30 UTC

Embedded resources? SqlMaps?

Hi again... 
 
New issue... 
 
I'm trying to embed some resourcefiles into my .dll, so that people do
not have to have all my .xml files with sql-statements to use it. 
 
I'm on linux -> mono and the compiler is mcs. This has a argument called
-resource:<filename>. I use this on all my .xml files when compiling and
this is my sqlmap.config: 
 
[snip] 
<?xml version=1.0 encoding=UTF-8 ?> 
<sqlMapConfig 
  xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance 
  xsi:noNamespaceSchemaLocation=SqlMapConfig.xsd> 
 
<properties resource=./Resources/Properties.xml/> 
 
<settings> 
<setting useStatementNamespaces=true/> 
<setting cacheModelsEnabled=true/> 
</settings> 
 
<database> 
<provider name=${provider}/> 
<dataSource name=budgetmodel.datamapper
connectionString=${connectionString}/> 
</database> 
 
<sqlMaps> 
<sqlMap embedded=AccessProfile.xml, BudgetModel.DataMapper/> 
<sqlMap embedded=BudgetPeriod.xml, BudgetModel.DataMapper/> 
<sqlMap embedded=BudgetValue.xml, BudgetModel.DataMapper/> 
<sqlMap embedded=NumberStyle.xml, BudgetModel.DataMapper/> 
<sqlMap embedded=Sequence.xml, BudgetModel.DataMapper/> 
<sqlMap embedded=StyleSheet.xml, BudgetModel.DataMapper/> 
<sqlMap embedded=UserData.xml, BudgetModel.DataMapper/> 
<sqlMap embedded=Page.xml, BudgetModel.DataMapper/> 
</sqlMaps> 
 
</sqlMapConfig> 
[snap] 
 
But when I try to use the .dll file on ASP.NET the following error
occures: 
 
[snip] 
 Unable to load embedded resource from assembly AccessProfile.xml,
BudgetModel.DataMapper. 
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code. 
 
Exception Details: IBatisNet.Common.Exceptions.ConfigurationException:
Unable to load embedded resource from assembly AccessProfile.xml,
BudgetModel.DataMapper. 
[snap] 
 
and the stack trace: 
 
[snip] 
[ConfigurationException: Unable to load embedded resource from assembly
AccessProfile.xml, BudgetModel.DataMapper.] 
  
IBatisNet.Common.Utilities.Resources.GetEmbeddedResourceAsXmlDocument(String
resource) +534 
   IBatisNet.Common.Utilities.Resources.GetAsXmlDocument(XmlNode node,
NameValueCollection properties) +215 
   IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.ConfigureSqlMap()
+375 
   IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Initialize()
+4358 
   IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument
document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean
isCallFromDao) +81 
 
[ConfigurationException: 
- The error occurred while loading SqlMap . 
- The error occurred in <sqlMap embedded=AccessProfile.xml,
BudgetModel.DataMapper />.] 
   IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument
document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean
isCallFromDao) +160 
  
IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.ConfigureAndWatch(String
resource, ConfigureHandler configureDelegate) +198 
   IBatisNet.DataMapper.Mapper.InitMapper() +65 
   IBatisNet.DataMapper.Mapper.Instance() +64 
   BudgetModel.Model.Helper.UserDataHelper.UserLogin(String username,
String uPassword) +164 
   BudgetModel.login.ok_Click(Object sender, EventArgs e) in
C:\Documents and
Settings\kel\VSWebCache\til.busieco.sdu.dk_1000\login.aspx.cs:103 
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108 
  
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +58 
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18 
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+33 
   System.Web.UI.Page.ProcessRequestMain() +1292 
[snap] 
 
What am I doing wrong? I can't seem to get anything to work with
embedding files... 
 
/morten 


Re: Embedded resources? SqlMaps?

Posted by Larry Meadors <la...@gmail.com>.
I had similar issues on win2k. I was using nant's csc task, and had to
tweak the resources element to get it to work correctly. Take a look
at the --resource options to mcs, I suspect you have a similar issue,
which was that the prefix from the config file (which is
BudgetModel.DataMapper) does not match the prefix in the DLL.

I am not sure what your options are with mono for examining the dll,
but look at the resources in the dll to see how they are named.

Larry


On 6/8/05, Morten Schmidt <sc...@knowledgelab.sdu.dk> wrote:
>  
>  Hi again... 
>   
> New issue... 
>   
> I'm trying to embed some resourcefiles into my .dll, so that people do not
> have to have all my .xml files with sql-statements to use it. 
>   
> I'm on linux -> mono and the compiler is mcs. This has a argument called
> -resource:<filename>. I use this on all my .xml files when compiling and
> this is my sqlmap.config: 
>   
> [snip] 
> <?xml version="1.0" encoding="UTF-8" ?> 
> <sqlMapConfig 
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
>   xsi:noNamespaceSchemaLocation="SqlMapConfig.xsd"> 
>   
> <properties resource="./Resources/Properties.xml"/> 
>   
> <settings> 
> <setting useStatementNamespaces="true"/> 
> <setting cacheModelsEnabled="true"/> 
> </settings> 
>   
> <database> 
> <provider name="${provider}"/> 
> <dataSource name="budgetmodel.datamapper"
> connectionString="${connectionString}"/> 
> </database> 
>   
> <sqlMaps> 
> <sqlMap embedded="AccessProfile.xml, BudgetModel.DataMapper"/> 
> <sqlMap embedded="BudgetPeriod.xml, BudgetModel.DataMapper"/> 
> <sqlMap embedded="BudgetValue.xml, BudgetModel.DataMapper"/> 
> <sqlMap embedded="NumberStyle.xml, BudgetModel.DataMapper"/> 
> <sqlMap embedded="Sequence.xml, BudgetModel.DataMapper"/> 
> <sqlMap embedded="StyleSheet.xml, BudgetModel.DataMapper"/> 
> <sqlMap embedded="UserData.xml, BudgetModel.DataMapper"/> 
> <sqlMap embedded="Page.xml, BudgetModel.DataMapper"/> 
> </sqlMaps> 
>   
> </sqlMapConfig> 
> [snap] 
>   
> But when I try to use the .dll file on ASP.NET the following error occures: 
>   
> [snip] 
>  Unable to load embedded resource from assembly "AccessProfile.xml,
> BudgetModel.DataMapper". 
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about the error and where it originated in the code. 
>   
> Exception Details:
> IBatisNet.Common.Exceptions.ConfigurationException: Unable
> to load embedded resource from assembly "AccessProfile.xml,
> BudgetModel.DataMapper". 
> [snap] 
>   
> and the stack trace: 
>   
> [snip] 
> [ConfigurationException: Unable to load embedded resource from assembly
> "AccessProfile.xml, BudgetModel.DataMapper".] 
>   
> IBatisNet.Common.Utilities.Resources.GetEmbeddedResourceAsXmlDocument(String
> resource) +534 
>   
> IBatisNet.Common.Utilities.Resources.GetAsXmlDocument(XmlNode
> node, NameValueCollection properties) +215 
>   
> IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.ConfigureSqlMap()
> +375 
>   
> IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Initialize()
> +4358 
>   
> IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument
> document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean
> isCallFromDao) +81 
>   
> [ConfigurationException: 
> - The error occurred while loading SqlMap . 
> - The error occurred in <sqlMap embedded="AccessProfile.xml,
> BudgetModel.DataMapper" />.] 
>   
> IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument
> document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean
> isCallFromDao) +160 
>   
> IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.ConfigureAndWatch(String
> resource, ConfigureHandler configureDelegate) +198 
>    IBatisNet.DataMapper.Mapper.InitMapper() +65 
>    IBatisNet.DataMapper.Mapper.Instance() +64 
>    BudgetModel.Model.Helper.UserDataHelper.UserLogin(String
> username, String uPassword) +164 
>    BudgetModel.login.ok_Click(Object sender, EventArgs e) in C:\Documents
> and
> Settings\kel\VSWebCache\til.busieco.sdu.dk_1000\login.aspx.cs:103
>    System.Web.UI.WebControls.Button.OnClick(EventArgs e)
> +108 
>   
> System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
> eventArgument) +58 
>   
> System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
> sourceControl, String eventArgument) +18 
>   
> System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
> postData) +33 
>    System.Web.UI.Page.ProcessRequestMain() +1292 
> [snap] 
>   
> What am I doing wrong? I can't seem to get anything to work with embedding
> files... 
>   
> /morten