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 Juliana Machado <ju...@hotmail.com> on 2009/11/17 13:44:09 UTC

asp.net mvc x library x ibatis

Hi!

Sorry my poor english ...

I have 2 projects: mvc application and another with the persistence database
(library). I need to have the configuration files ibatis (sqlmap, providers,
xmls) also in the application to MVC all work? Because I can run locally
ibatis when put into this project mvc, but not when put in the library.

Thanks! :)
-- 
View this message in context: http://old.nabble.com/asp.net-mvc-x-library-x-ibatis-tp26389285p26389285.html
Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-cs-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-cs-help@ibatis.apache.org


Re: asp.net mvc x library x ibatis

Posted by Juliana Machado <ju...@hotmail.com>.
Michael

I managed to run this persistence project using ibatis. I put the configs
and xmls files within the application and reference the ibatis dlls in the
persistence project.

It's working, very good!! :)

And I did not need to set in Application_Start the path where the
sqlmap.config is, because ibatis search the configs files in the root of the
application, in the same place where the web.config is

But now ...... I need to put a wcf service between the 2 projects. The mvc
application calls the service and the service calls the persistence project.
The problem is that when I run the application, the service needs
sqlmap.config! The error is:

Unable to load file via resource "SqlMap.config" the resource. Cause: Could
not find file 'C: \ .......... \ WCF \ WcfService \ SqlMap.config'.

And when I put sqlmap.config (providers.config, xmls) within the service,
gives the following error:

- The error occurred while loading sqlmap.
- Initialize ResultMap
- The error occurred in <sqlMap resource="Config/Maps/xxx.xml"
xmlns="http://ibatis.apache.org/dataMapper" />.
- Check the xxxmNamespace.xxxResult.

I'm lost as to what I have to do: (
-- 
View this message in context: http://old.nabble.com/asp.net-mvc-x-library-x-ibatis-tp26389285p26396021.html
Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-cs-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-cs-help@ibatis.apache.org


Re: asp.net mvc x library x ibatis

Posted by Michael McCurrey <mm...@gmail.com>.
No problem, I'll see if I can help.  This might just a problem with how your
loading your SqlMap.config file.   How are you loading it?  From a file
location or as an embedded resource?

On Tue, Nov 17, 2009 at 5:44 AM, Juliana Machado <
juliana.machado.85@hotmail.com> wrote:

>
> Hi!
>
> Sorry my poor english ...
>
> I have 2 projects: mvc application and another with the persistence
> database
> (library). I need to have the configuration files ibatis (sqlmap,
> providers,
> xmls) also in the application to MVC all work? Because I can run locally
> ibatis when put into this project mvc, but not when put in the library.
>
> Thanks! :)
> --
> View this message in context:
> http://old.nabble.com/asp.net-mvc-x-library-x-ibatis-tp26389285p26389285.html
> Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-cs-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-cs-help@ibatis.apache.org
>
>


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

Re: asp.net mvc x library x ibatis

Posted by Michael Schall <mi...@gmail.com>.
We configure ibatis in the Application_Start method of the website and
have the configuration files reside in the root of the website.

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)

	Dim applicationBase As String =
System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase

	Dim log4netPath As String = Path.Combine(applicationBase, "Web.log4net.config")
	Dim sqlConfigPath As String = Path.Combine(applicationBase,
"Web.SqlMap.config")

	If File.Exists(log4netPath) Then
		'Configure log4net
	Else
		Throw New System.InvalidOperationException("Unable to find logging
configuration file at " & log4netPath)
	End If

	If File.Exists(sqlConfigPath) Then
		'Configure ibatis
	Else
		Throw New System.InvalidOperationException("Unable to find sql map
configuration file at " & sqlConfigPath)
	End If

	...

End Sub


On Tue, Nov 17, 2009 at 8:15 AM, Juliana Machado
<ju...@hotmail.com> wrote:
>
> Michael,
>
> Files: sqlmap.config, Providers.config (xxx.xml, yyy.xml) are all within the
> persistence project, in the root of this project.
>
> and the error that appears is: Unable to load file via resource
> "SqlMap.config" as resource. Cause : Could not find file
> --
> View this message in context: http://old.nabble.com/asp.net-mvc-x-library-x-ibatis-tp26389285p26390593.html
> Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-cs-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-cs-help@ibatis.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-cs-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-cs-help@ibatis.apache.org


Re: asp.net mvc x library x ibatis

Posted by Juliana Machado <ju...@hotmail.com>.
Michael,

Files: sqlmap.config, Providers.config (xxx.xml, yyy.xml) are all within the
persistence project, in the root of this project.

and the error that appears is: Unable to load file via resource
"SqlMap.config" as resource. Cause : Could not find file 
-- 
View this message in context: http://old.nabble.com/asp.net-mvc-x-library-x-ibatis-tp26389285p26390593.html
Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-cs-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-cs-help@ibatis.apache.org


Re: asp.net mvc x library x ibatis

Posted by Juan Pablo Araya <ju...@gmail.com>.
Juliana:

The configuration depends on the context where you run the
application. In your case, if you run from your MVC project then you
should have your xml files in the MVC, not the persistence library.
The same if you run it in a console application, you should have your
xml files in the directory of the application, because iBatis open the
files per directory inside the context.

A feasible option in which you can have all inside the persistence
library is to embed the xml files (embedded resource propertie of each
xml file). With this, the xml get compiled in your persistance
library. In order to do this, you must code your own Mapper class in
which at the moment of configuring himself (InitMapper() method) it
load the embedded files:

XmlDocument sqlMapConfig =
Resourcs.GetEmbeddedResourceAsXmlDocument("Config.sqlMap.config,
Your.Library.Assemblie");

Check the following link

http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+use+an+embedded+sqlMap.config+file


------------------
La configuración depende mucho del contexto donde corras la
aplicación. En tu caso, si lo corres desde tu proyecto MVC deberías
tener los xml en el MVC y no en la librería. Lo mismo si lo corres en
consola, debes dejarlos en el directorio de la consola ya que iBatis
abre los archivos por directorio, dentro del contexto.

Una opción para que puedas tenerlo todo dentro de la librería y te
olvides de los archivos, es que todos tus XML tengan la propiedad
"embedded resource". Con eso, los xml se compilan dentro de tu
librería de persistencia. Para esto, debes crear tu propia clase
Mapper, en la cual al momento de configurarse (método InitMapper())
cargue los archivos embedidos:

XmlDocument sqlMapConfig =
Resourcs.GetEmbeddedResourceAsXmlDocument("Config.sqlMap.config,
Your.Library.Assemblie");

Revisa el siguiente link donde explican todo paso a paso:

http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+use+an+embedded+sqlMap.config+file

2009/11/17 Juliana Machado <ju...@hotmail.com>:
>
> Hi!
>
> Sorry my poor english ...
>
> I have 2 projects: mvc application and another with the persistence database
> (library). I need to have the configuration files ibatis (sqlmap, providers,
> xmls) also in the application to MVC all work? Because I can run locally
> ibatis when put into this project mvc, but not when put in the library.
>
> Thanks! :)
> --
> View this message in context: http://old.nabble.com/asp.net-mvc-x-library-x-ibatis-tp26389285p26389285.html
> Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-cs-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-cs-help@ibatis.apache.org
>
>



-- 
Juan Pablo Araya
787 76 034

---------------------------------------------------------------------
To unsubscribe, e-mail: user-cs-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-cs-help@ibatis.apache.org