PDA

View Full Version : Data access synchronization


Aleksei Kachanov
07-17-2006, 10:04 AM
I don't know how to explain the problem and the reason of the problem...

I have web application which use Spring & NHibernate.
Use DAO pattern and transactions.
When we run concurrently two browser to access data we failed with exception...
Each time exception are different ... :(
During research found that exception failed in
Spring.Aop.Framework.DynamicProxy.CompositionProxy Builder
in
[CODE]
public Type BuildProxy(IAdvised advised)
foreach (DictionaryEntry entry in _targetMethods)
{
FieldInfo field = proxyType.GetField((string)entry.Key, BindingFlags.NonPublic | BindingFlags.Static);
field.SetValue(proxyType, (MethodInfo)entry.Value); // -- NUL L REFERENCE or Collection was modified
}

Maybe I have wrong configuration .... or ..
Can anybody help to resolve this problem?

Execute said code by

public IList GetTeacherList(Institution institution)
{
return (IList)HibernateTemplate.Execute(delegate(ISession session)
{
ICriteria criteria = session.CreateCriteria(typeof(Teacher))
.Add(Expression.Eq("Institution", institution)).AddOrder(new Order("FullName", true)).AddOrder(new Order("UserID", true));
return criteria.List();
});
}



P.S. Use the latest night build Spring.NET-20060711-2205

Mark Pollack
07-19-2006, 08:51 PM
Hi,
Can you post at least one of your exceptions. The thread local storage used currently to bind the hibernate session to the thread is not sufficient for all cases in a web application. We need to instead store it in HttpContext.Items. See http://forum.springframework.net/showthread.php?t=572 for more info. Also, are any of the objects displayed in your page lazily loaded from hiberate?
Cheers,
Mark

Aleksei Kachanov
07-20-2006, 10:08 AM
Hi, Mark
We found bug related to this problem, I have posted it to jira
SPRNET-340 (http://opensource.atlassian.com/projects/spring/browse/SPRNET-340)

field.SetValue(proxyType, (MethodInfo)entry.Value);
System.NullReferenceException: Object reference not set to an instance of an object.
`field` is null.

foreach (DictionaryEntry entry in _targetMethods)
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.

This exceptions causes more often.

Bruno Baia
07-21-2006, 10:52 AM
Thanks Aleksei !
I'll take a look as i'm working on Spring.Aop.

It should fixes this one too :
http://forum.springframework.net/showthread.php?t=597


-Bruno

Aleksei Kachanov
07-24-2006, 03:09 PM
What about http://opensource.atlassian.com/projects/spring/browse/SPRNET-340
and our fix to it?

Bruno Baia
07-24-2006, 03:39 PM
I'm currently working on Spring.Aop to allow classes to be proxied without the need to implement an interface (ProxyTargetType = True), so it should be fixed when the new implementation will be commited.

Bruno

Bruno Baia
08-11-2006, 01:12 AM
Hi Aleksei,

The fix has been commited.
Give a try to the latest nightly build and tell us how's working.

-Bruno