garypayton
11-29-2005, 04:00 PM
Hi
I do an example and get this exception: Existing context 'Spring.Context.Support.WebApplicationContext' already registered under name '/yosemite'. (of course "yosemite" is my peroject name)
My example is using a frameset page which include two aspx page (Left.aspx and Content.aspx), I registered these pages in configuration file like
<spring>
<context type="Spring.Context.Support.WebApplicationContext, Spring.Web">
<resource uri="config://spring/objects" />
</context>
<objects xmlns="http://www.springframework.net">
<object type="~/Management/Left.aspx" />
<object type="~/Management/Content.aspx" />
</objects>
</spring>
when I open the frameset page,one of the two frame pages always throw that exception. Even worse sometimes is Left.aspx,sometimes is Content.aspx and it only happed when the appdomain is firstly initialized.After more investigation, I thought it maybe caused by synchronously accessing shared resource. I traced the spring.web source code Web/Support/PageHandlerFactory.cs PageHandlerFactory.GetHandler method, it had this code snippetIApplicationContext appContext = GetApplicationContext(context);
I found when each one initialized here, first one is ok,senconde one is failed and thrown Existing context 'Spring.Context.Support.WebApplicationContext' already registered under name '/yosemite'.
What's your idea?
After I edit upper code to
IApplicationContext appContext;
lock(typeof(PageHandlerFactory))
{
appContext = GetApplicationContext(context);
}
exception disappeared...........
I don't know why context.GetConfig failed in this case, but my experiences tell me most of dotnet method is not thread safe.
Hehe, if it is really a problem and you need more staff, please contact me. I expect your answer.
I do an example and get this exception: Existing context 'Spring.Context.Support.WebApplicationContext' already registered under name '/yosemite'. (of course "yosemite" is my peroject name)
My example is using a frameset page which include two aspx page (Left.aspx and Content.aspx), I registered these pages in configuration file like
<spring>
<context type="Spring.Context.Support.WebApplicationContext, Spring.Web">
<resource uri="config://spring/objects" />
</context>
<objects xmlns="http://www.springframework.net">
<object type="~/Management/Left.aspx" />
<object type="~/Management/Content.aspx" />
</objects>
</spring>
when I open the frameset page,one of the two frame pages always throw that exception. Even worse sometimes is Left.aspx,sometimes is Content.aspx and it only happed when the appdomain is firstly initialized.After more investigation, I thought it maybe caused by synchronously accessing shared resource. I traced the spring.web source code Web/Support/PageHandlerFactory.cs PageHandlerFactory.GetHandler method, it had this code snippetIApplicationContext appContext = GetApplicationContext(context);
I found when each one initialized here, first one is ok,senconde one is failed and thrown Existing context 'Spring.Context.Support.WebApplicationContext' already registered under name '/yosemite'.
What's your idea?
After I edit upper code to
IApplicationContext appContext;
lock(typeof(PageHandlerFactory))
{
appContext = GetApplicationContext(context);
}
exception disappeared...........
I don't know why context.GetConfig failed in this case, but my experiences tell me most of dotnet method is not thread safe.
Hehe, if it is really a problem and you need more staff, please contact me. I expect your answer.