View Full Version : DataQuickstart
Richard12345
06-06-2007, 05:16 PM
I'm trying to introduce SpringFramework.net to a good size investement bank in NYC. It seems like a nice product. I realize that initial configuration can be a bit frustrating with any product, etc. I've spent 3 days on trying to get the DataQuick and SpringAir working with little success. OK so its a wonderful day :-D . Maybe someone can help me out.
Spring.NET 1.1 M1 - VS2005 - DataQuickStart - builds no errors.
Modified C:\Program Files\Spring.NET 1.1 M1\examples\Spring\Spring.DataQuickStart\test\Spri ng\Spring.DataQuickStart.Tests\DataQuickStart\Gene ricTemplate\ExampleTests.xml to point to our SQL Server 6.5 server (it's a bit old but our SQL2005 server does not have the NorthWind database), with sa userid and password.
NUnit 2.4.1 - (I'm new to NUnit) - New project Spring.NET 1.1 M1\Project1, added dll C:\Program Files\Spring.NET 1.1 M1\examples\Spring\Spring.DataQuickStart\test\Spri ng\Spring.DataQuickStart.Tests\bin\Debug\Spring.Da taQuickStart.Tests.dll
Run GenericTemplate\ExampleTests\CallBackDaoTest gives this error:
Spring.DataQuickStart.GenericTemplate.ExampleTests .CallbackDaoTest : Spring.Objects.Factory.ObjectDefinitionStoreExcept ion : XmlException parsing XML document from assembly [Spring.DataQuickStart.Tests, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null], resource [Spring.DataQuickStart.GenericTemplate.ExampleTests .xml]
----> System.Xml.XmlException : The 'http://www.springframework.net/database:dbProvider' element is not declared.
----> System.Xml.Schema.XmlSchemaValidationException : The 'http://www.springframework.net/database:dbProvider' element is not declared.
Bruno Baia
06-06-2007, 06:23 PM
Hi,
I think you forgot to configure the 'http://www.springframework.net/database' namespace parser.
Reference documentation : 17.3. XML based configuration (http://www.springframework.net/doc-latest/reference/html/dbprovider.html#d0e9709)
I've just updated the docs, but this is enough :
<parser type="Spring.Data.DatabaseConfigParser, Spring.Data" />
(no need to specify namespace or schemaLocation)
Take a look to the Spring.DataQuickStart.Tests.dll.config in the Spring.DataQuickStart.Tests project for an example.
(it's a bit old but our SQL2005 server does not have the NorthWind database)
You can download the NorthWind database here :
http://www.microsoft.com/downloads/details.aspx?FamilyID=06616212-0356-46a0-8da2-eebc53a68034&displaylang=en
HTH,
Bruno
Richard12345
06-06-2007, 07:21 PM
<parser type="Spring.Data.DatabaseConfigParser, Spring.Data" />
was already in C:\Program Files\Spring.NET 1.1 M1\examples\Spring\Spring.DataQuickStart\test\Spri ng\Spring.DataQuickStart.Tests\Spring.DataQuickSta rt.Tests.dll.config
I have not changed anything after downloading 1.1 M1
Thanks for the tip on downloading Northwind. I have it now on my localhost database engine. I added user sqringqa to it.
Here is the config file as downloaded.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
<sectionGroup name="spring">
<section name="parsers" type="Spring.Context.Support.ConfigParsersSectionHandler , Spring.Core" />
</sectionGroup>
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.Simple.ConsoleOutLoggerFactoryAdapt er, Common.Logging">
<arg key="showLogName" value="true" />
<arg key="showDataTime" value="true" />
<arg key="level" value="INFO" />
<arg key="dateTimeFormat" value="yyyy/MM/dd HH:mm:ss:fff" />
</factoryAdapter>
</logging>
</common>
<spring>
<parsers>
<parser type="Spring.Data.DatabaseConfigParser, Spring.Data" />
</parsers>
</spring>
</configuration>
Here is ExampleTests.xml as downloaded:
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
xmlns:db="http://www.springframework.net/database">
<db:dbProvider id="dbProvider"
provider="SqlServer-1.1"
connectionString="Data Source=(local);Database=Northwind;User ID=springqa;Password=springqa;Trusted_Connection=F alse"/>
<object id="adoTemplate" type="Spring.Data.Generic.AdoTemplate, Spring.Data">
<property name="DbProvider" ref="dbProvider"/>
<property name="DataReaderWrapperType" value="Spring.Data.Support.NullMappingDataReader, Spring.Data"/>
</object>
<object id="commandCallbackDao" type="Spring.DataQuickStart.Dao.GenericTemplate.CommandC allbackDao, Spring.DataQuickStart">
<property name="AdoTemplate" ref="adoTemplate"/>
</object>
<object id="resultSetExtractorDao" type="Spring.DataQuickStart.Dao.GenericTemplate.ResultSe tExtractorDao, Spring.DataQuickStart">
<property name="AdoTemplate" ref="adoTemplate"/>
</object>
<object id="rowMapperDao" type="Spring.DataQuickStart.Dao.GenericTemplate.RowMappe rDao, Spring.DataQuickStart">
<property name="AdoTemplate" ref="adoTemplate"/>
</object>
<object id="rowCallbackDao" type="Spring.DataQuickStart.Dao.GenericTemplate.RowCallb ackDao, Spring.DataQuickStart">
<property name="AdoTemplate" ref="adoTemplate"/>
</object>
<object id="queryForObjectDao" type="Spring.DataQuickStart.Dao.GenericTemplate.Queryfor ObjectDao, Spring.DataQuickStart">
<property name="AdoTemplate" ref="adoTemplate"/>
</object>
</objects>
Bruno Baia
06-06-2007, 08:52 PM
Hi,
read this thread :
http://forum.springframework.net/showthread.php?t=2877
Maybe you are doing the same mistake.
HTH,
Bruno
Richard12345
06-06-2007, 09:09 PM
I tried the Spring.Northwind example which worked as downloaded. Now that I understand the examples, most likely nHibernate will be the way to go for my purposes.
Bruno Baia
06-06-2007, 10:25 PM
Hi Richard,
As you could see, there is an error in the Spring.DataQuickStart 1.1 M1 example :
See this thread :
Fix for Spring.DataQuickStart 1.1 M1 example (http://forum.springframework.net/showthread.php?t=2889)
Bruno
Richard12345
06-07-2007, 06:25 PM
That thread worked. But I also needed to add:
using Spring.Data;
using Spring.Objects.Factory.Xml;
Richard12345
06-07-2007, 06:33 PM
I was still unable to do the test but I don't think it's a problem with spring or nunit. I think it's related to a situation with our policy here at work. I can't unset read-only on the bin folder (even using cmd.exe) for some reason. The folder has NT permissions for Everyone to full everything. I'll try it on my machine at home later.
Spring.DataQuickStart.GenericTemplate.ExampleTests .CallbackDaoTest : System.UnauthorizedAccessException : Access to the path 'C:\aSpring\Spring.DataQuickStart\test\Spring\Spri ng.DataQuickStart.Tests\bin' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at Spring.Core.IO.FileSystemResource.get_InputStream( )
at Spring.Objects.Factory.Xml.XmlObjectDefinitionRead er.LoadObjectDefinitions(IResource resource)
at Spring.Objects.Factory.Support.AbstractObjectDefin itionReader.LoadObjectDefinitions(String location)
at Spring.Objects.Factory.Support.AbstractObjectDefin itionReader.LoadObjectDefinitions(String[] locations)
at Spring.Context.Support.AbstractXmlApplicationConte xt.LoadObjectDefinitions(XmlObjectDefinitionReader objectDefinitionReader)
at Spring.Context.Support.AbstractXmlApplicationConte xt.LoadObjectDefinitions(DefaultListableObjectFact ory objectFactory)
at Spring.Context.Support.AbstractXmlApplicationConte xt.RefreshObjectFactory()
at Spring.Context.Support.AbstractApplicationContext. Refresh()
at Spring.Context.Support.XmlApplicationContext..ctor (String name, Boolean caseSensitive, IApplicationContext parentContext, String[] configurationLocations)
at Spring.Context.Support.XmlApplicationContext..ctor (String[] configurationLocations)
at Spring.DataQuickStart.GenericTemplate.ExampleTests .InitContext() in C:\aSpring\Spring.DataQuickStart\test\Spring\Sprin g.DataQuickStart.Tests\DataQuickStart\GenericTempl ate\ExampleTests.cs:line 24
Bruno Baia
06-07-2007, 09:07 PM
That thread worked. But I also needed to add:
using Spring.Data;
using Spring.Objects.Factory.Xml;
Yep.
You can see all changes (http://fisheye1.cenqua.com/changelog/springnet/Spring.Net/examples?cs=MAIN:bbaia:20070606205337) I made with fisheye :
diffs with in fisheye.
Bruno Baia
06-07-2007, 09:13 PM
at Spring.Core.IO.FileSystemResource.get_InputStream( )
The DataQuickStart example uses assembly resources (assembly://), have you changed it to use a FileSystemResource ?
You should not have problems with Assembly resources.
Bruno
Richard12345
06-07-2007, 10:50 PM
The generic template now works after comparing the fisheye changes. I did not have the assembly thing.
The template example gives this error, although the sp is in the database:
Spring.DataQuickStart.Template.ExampleTests.QueryF orDetailsUsingStoredProcObject : Spring.Objects.Factory.NoSuchObjectDefinitionExcep tion : No object named 'custOrdersDetailStoredProc' is defined : Cannot find definition for object [custOrdersDetailStoredProc]
at Spring.Objects.Factory.Support.AbstractObjectFacto ry.GetObject(String name, Type requiredType, Object[] arguments)
at Spring.Objects.Factory.Support.AbstractObjectFacto ry.GetObject(String name, Object[] arguments)
at Spring.Objects.Factory.Support.AbstractObjectFacto ry.GetObject(String name)
at Spring.Context.Support.AbstractApplicationContext. get_Item(String name)
at Spring.DataQuickStart.Template.ExampleTests.QueryF orDetailsUsingStoredProcObject() in C:\aSpring\Spring.DataQuickStart\test\Spring\Sprin g.DataQuickStart.Tests\DataQuickStart\Template\Exa mpleTests.cs:line 101
Bruno Baia
06-08-2007, 03:36 PM
Hi,
Both examples work fine here.
A problem I can see is that your using the .xml configuration file for Generic Templates with the tests for basic templates, because the test with "custOrdersDetailStoredProc" object is for basic templates.
Take a look to the SetUp method of test class to check that, maybe a bas copy/paste.
HTH,
Bruno
Mark Pollack
06-26-2007, 05:30 PM
Hi,
Very strange error, the examples run fine for me out of the box using either TestDriven.NET or Resharper. I will change the examples to be console application in the future, as I think this is causing some issues.
In anycase, do you see the object definition for
custOrdersDetailStoredProc in the file DataQuickStart/Template/ExampleTests.xml? That is the file that needs to be loaded, maybe with your experimenting things got switched around as Bruno suggested. Make sure you have the following in Spring.DataQuickStart.Template.ExampleTests.cs,
[SetUp]
public void InitContext()
{
ctx =
new XmlApplicationContext("assembly://Spring.DataQuickStart.Tests/Spring.DataQuickStart.Template/ExampleTests.xml");
}
Let me know the status of your eval, hope this helps.
Cheers,
Mark
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.