Error message reported when "deactivating" Crucible user
Symptoms
When trying to disable the "Active Crucible user" option in a user profile, the following error is reported in the browser:
In the log file, the following is reported:
INFO [btpool0-3731 ] fisheye.app TotalityFilter-logExceptionDetails - Exception "org.hibernate.NonUniqueResultException: query did not return a unique result: 2" (javax.servlet.ServletException) while processing "/admin/userEdit.do" (Referer:"http://localhost:8060/admin/userEdit-default.do")
javax.servlet.ServletException: org.hibernate.NonUniqueResultException: query did not return a unique result: 2
at com.opensymphony.webwork.dispatcher.DispatcherUtils.serviceAction(DispatcherUtils.java:284)
at com.opensymphony.webwork.dispatcher.ServletDispatcher.service(ServletDispatcher.java:111)
...
...
...
Caused by: org.hibernate.NonUniqueResultException: query did not return a unique result: 2
at org.hibernate.impl.AbstractQueryImpl.uniqueElement(AbstractQueryImpl.java:868)
at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:859)
at com.atlassian.fecru.user.UserDAOImpl.getUsernameByEmail(UserDAOImpl.java:105)
at com.cenqua.fisheye.user.DefaultUserManager.getUsernameByEmail(DefaultUserManager.java:1358)
at sun.reflect.GeneratedMethodAccessor3248.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196)
at $Proxy27.getUsernameByEmail(Unknown Source)
at com.cenqua.fisheye.web.admin.actions.user.UserEditAction.validate(UserEditAction.java:91)
Cause
The Fisheye/Crucible instance was integrated with an external User Directory Server (Crowd, JIRA or LDAP) and a user from the external server had the same email as one of the Built-in users that already existed in the application database.
Resolution
The problem can be resolved by changing the email of one of the users (you may want to do this to the user that you are trying to disable).
Run the following query to identify duplicated e-mail addresses:
SELECT cru_email, COUNT(cru_email) AS Entries
FROM cru_user GROUP BY cru_email HAVING (COUNT(cru_email) > 1)
Resolution #1 (preferred)
Change the e-mail address of one of the users that have duplicated e-mails.
Resolution #2
For each of the repeated emails, identify the users and update them so that emails can be unique again:
UPDATE
cru_user
SET
cru_email = 'new@email.com'
WHERE
cru_user_id = 123456
(you can replace the "123456" string using the real user ID to have its email changed).