first ,please look my exception infos in below:
exception time:2013-10-15 09:08:30,765 [1]
exception level:ERROR
exception class:logerror [(null)]
SpringFactory.GetObject(adminFacade)
System.InvalidOperationException: root context is currently in creation. You must not call ContextRegistry.GetContext() from e.g. constructors of your singleton objects
at Spring.Context.Support.ContextRegistry.InitializeContextIfNeeded()
at Spring.Context.Support.ContextRegistry.GetContext()
at Domain.common.SpringFactory.GetObject(String objectId) in F:\gitlab\huatongmis.git\HuaTongBusinessWeb\Domain\common\SpringFactory.cs:line 38
there are some exception infos like that in my project log files,actually it does not make my project break down. but I treat it as a terrible problem.it puzzled me for a long time.
please see the exception point in my code file.
public class SpringFactory
{
private static IApplicationContext _applicationContext;
private SpringFactory(){}
public static Object GetObject(string objectId)
{
try
{
if (_applicationContext == null)
{
_applicationContext = ContextRegistry.GetContext();
}
}
catch (Exception ex)
{
LogHelper.WriteLog(string.Format("SpringFactory.GetObject({0})",objectId), ex);
}
return _applicationContext.GetObject(objectId);
}
}
I use the IOc just like this
public class Order : System.Web.Services.WebService
{
public HTSoapHeader htSoapHeader;
private OrderFacade orderFacade { get; set; }
private TicketFacade ticketFacade { get; set; }
private CarrentalFacade carrentalFacade { get; set; }
private AdminFacade adminFacade { get; set; }
public Order()
{
orderFacade = (OrderFacade)SpringFactory.GetObject("orderFacade");
ticketFacade = (TicketFacade)SpringFactory.GetObject("ticketFacade");
carrentalFacade = (CarrentalFacade)SpringFactory.GetObject("carrentalFacade");
adminFacade = (AdminFacade)SpringFactory.GetObject("adminFacade");
}
}
how it happened and how to solve the problem.
looking forward to having your any answer, thanks