We recently ran into an issue where a client was suddenly unable to login to the web client at all. As soon as they entered their credentials into the Login page, an error would occur. Looking into the event logs the stack trace was:
“message”: “query did not return a unique result: 2.”,
“source”: “NHibernate.Impl.AbstractQueryImpl, NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4”,
“type”: “NHibernate.NonUniqueResultException”,
“stackTrace”: ” at NHibernate.Impl.AbstractQueryImpl.UniqueElement(IList list)\r\n at NHibernate.Impl.CriteriaImpl.UniqueResult[T]()\r\n at NHibernate.Criterion.QueryOver`1.SingleOrDefault()\r\n at NHibernate.Criterion.QueryOver`1.NHibernate.IQueryOver
“targetSite”: “System.Object UniqueElement(System.Collections.IList)”,
“fullException”: “System.Web.HttpUnhandledException (0x80004005): Exception of type ‘System.Web.HttpUnhandledException’ was thrown. —> NHibernate.NonUniqueResultException: query did not return a unique result: 2\r\n at NHibernate.Impl.AbstractQueryImpl.UniqueElement(IList list)\r\n at NHibernate.Impl.CriteriaImpl.UniqueResult[T]()\r\n at NHibernate.Criterion.QueryOver`1.SingleOrDefault()\r\n at NHibernate.Criterion.QueryOver`1.NHibernate.IQueryOver
After turning on Nhibernate logging using Log4Net I was able to find the problem. So you don’t have to go through that lets see what is going on…
The specific issue is that there is a duplicate row being added into the CUSTOMSETTINGS table. The row was something with CATEGORY=”LocaleConfig” and DESCRIPTION containing “{some value}|webclientLocaleConfig”.
I reviewed the code base of the SLX web client. The only place that writes this value to the CUSTOMSETTINGS table for LocaleConfig row is by going to the web client’s Administration/Office Profiles and then opening the detail record. On the detail screen there is a Help tab. On that tab is a Supported Languages drop down for the web client. When you press the Save button on that tab it calls a standard method called: UpdateLocaleConfig.
This UpdateLocaleConfig code is as follows:
string key = officeprofile.Id.ToString() + "|" + portalName + "LocaleConfig";
MySlx.Data.RemoveFromCache(key);
var factory = EntityFactory.GetRepository<ICustomSetting>();
ICustomSetting setting = factory.FindFirstByProperty("DataKey", key);
if (setting != null) {
setting.DataValue = localeCSV;
}
else {
setting = EntityFactory.Create<ICustomSetting>();
setting.DataKey = key;
setting.Description = key;
setting.Category = "LocaleConfig";
setting.DataValue = localeCSV;
setting.DataType = "Other";
setting.DataValidation = "Any Characters";
}
setting.Save();
The issue here is that it attempts to find the CUSTOMSETTINGS row matching on DATAKAEY using the variable “key” which using the value officeprofile.Id + “|” + portal name + “LocaleConfig.
The issue is that the original row in the CUSTOMSETTINGS table had a datakey value of “7Hrp|Webclientlocaleconfig”. However this code takes the officeprofile.Id and appends that to the rest of the formatted string. The officeprofile.Id is actually a database char(12) field, meaning that the officeprofile.Id returned is not just “7Hrp” but is in fact “7Hrp “. The resulting value it looks for is “7HRP |webclientLocaleConfig”. Since it does not find a row matching “7HRP |webclientLocaleConfig”, because the existing row is “7Hrp|Webclientlocaleconfig”, it adds a new row. This is where the problem comes from.
Other code in the system looks for the CUSTOMSETTINGS value by matching on CATEGORY and DESCRIPTION. When searched this way it finds two matching rows and the system errors out and results in what Harbert saw. By removing the duplicate erroneously added row the web client could log back in.
This does still appear to be an issue in the latest 9.3 version. So if you are receiving this error, hopefully this post will help you to fix things. Infor should change that UpdateLocaleConfig method to get the key value using a trimmed version of the Id, like so:
string key = officeprofile.Id.ToString().Trim() + "|" + portalName + "LocaleConfig";



