org.hibernate.NonUniqueResultException: query did not return a unique result: 2

Atlassian JIRA | Shayne Covey [Atlassian] | 10 months ago
  1. 0

    It is possible for duplicate entries to exist in HipChat Server's _crowd_ database tables, leading to failed synchronizations with external user directories. h3. Environment * HipChat Server v1.3.4 or v1.3.7 * Configured to synchronize with an external user directory (LDAP, Crowd, Active Directory, etc.) h3. Steps to Reproduce The steps to reproduce the root cause of this behavior are not currently known. h3. Expected Results Synchronization with external user directory is successful. h3. Actual Results Synchronization with the external directory fails, as reflected at {{Server admin >> Directory}}. h5. Scenario 1 - duplicate row in _cwd_membership_ The below exception is thrown in the _/home/admin/logs/atlassian-crowd.log_ file: *com.atlassian.crowd.dao.membership.MembershipDAOHibernate.findInternalMembership* {noformat} 2015-12-03 09:51:06,437 scheduler_Worker-4 ERROR [atlassian.crowd.directory.DbCachingDirectoryPoller] Error occurred while refreshing the cache for directory [ 393217 ]. org.hibernate.NonUniqueResultException: query did not return a unique result: 2 at org.hibernate.internal.AbstractQueryImpl.uniqueElement(AbstractQueryImpl.java:918) at org.hibernate.internal.CriteriaImpl.uniqueResult(CriteriaImpl.java:396) at com.atlassian.crowd.dao.membership.MembershipDAOHibernate.findInternalMembership(MembershipDAOHibernate.java:370) at com.atlassian.crowd.dao.membership.MembershipDAOHibernate.isUserDirectMember(MembershipDAOHibernate.java:213) at com.atlassian.crowd.directory.AbstractInternalDirectory.isUserDirectGroupMember(AbstractInternalDirectory.java:893) at com.atlassian.crowd.directory.AbstractInternalDirectory.removeUserFromGroup(AbstractInternalDirectory.java:945) at com.atlassian.crowd.directory.DbCachingRemoteChangeOperations.removeUserMembershipsForGroup(DbCachingRemoteChangeOperations.java:812) at sun.reflect.GeneratedMethodAccessor170.invoke(Unknown Source) {noformat} h5. Scenario 2 - duplicate row in _cwd_user_ The below exception is thrown in the _/home/admin/logs/atlassian-crowd.log_ file: *com.atlassian.crowd.dao.user.UserDAOHibernate.findByExternalId* {noformat} 2016-01-28 17:50:02,838 scheduler_Worker-5 ERROR [atlassian.crowd.directory.DbCachingDirectoryPoller] Error occurred while refreshing the cache for directory [ 425985 ]. org.hibernate.NonUniqueResultException: query did not return a unique result: 2 at org.hibernate.internal.AbstractQueryImpl.uniqueElement(AbstractQueryImpl.java:918) at org.hibernate.internal.CriteriaImpl.uniqueResult(CriteriaImpl.java:396) at com.atlassian.crowd.dao.user.UserDAOHibernate.findByExternalId(UserDAOHibernate.java:213) at com.atlassian.crowd.dao.user.UserDAOHibernate.findByExternalId(UserDAOHibernate.java:55) at com.atlassian.crowd.directory.AbstractInternalDirectory.findUserByExternalId(AbstractInternalDirectory.java:182) at com.atlassian.crowd.directory.DbCachingRemoteChangeOperations.userByExternalIdOrNull(DbCachingRemoteChangeOperations.java:293) at com.atlassian.crowd.directory.DbCachingRemoteChangeOperations.updateUsers(DbCachingRemoteChangeOperations.java:233) at sun.reflect.GeneratedMethodAccessor464.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) {noformat} h3.Workaround A workaround exists for this behavior, but may require direct database modification. Please [contact HipChat Server Support| https://support.atlassian.com/servicedesk/customer/portal/31] for assistance.

    Atlassian JIRA | 10 months ago | Shayne Covey [Atlassian]
    org.hibernate.NonUniqueResultException: query did not return a unique result: 2
  2. 0

    It is possible for duplicate entries to exist in HipChat Server's _crowd_ database tables, leading to failed synchronizations with external user directories. h3. Environment * HipChat Server v1.3.4 or v1.3.7 * Configured to synchronize with an external user directory (LDAP, Crowd, Active Directory, etc.) h3. Steps to Reproduce The steps to reproduce the root cause of this behavior are not currently known. h3. Expected Results Synchronization with external user directory is successful. h3. Actual Results Synchronization with the external directory fails, as reflected at {{Server admin >> Directory}}. h5. Scenario 1 - duplicate row in _cwd_membership_ The below exception is thrown in the _/home/admin/logs/atlassian-crowd.log_ file: *com.atlassian.crowd.dao.membership.MembershipDAOHibernate.findInternalMembership* {noformat} 2015-12-03 09:51:06,437 scheduler_Worker-4 ERROR [atlassian.crowd.directory.DbCachingDirectoryPoller] Error occurred while refreshing the cache for directory [ 393217 ]. org.hibernate.NonUniqueResultException: query did not return a unique result: 2 at org.hibernate.internal.AbstractQueryImpl.uniqueElement(AbstractQueryImpl.java:918) at org.hibernate.internal.CriteriaImpl.uniqueResult(CriteriaImpl.java:396) at com.atlassian.crowd.dao.membership.MembershipDAOHibernate.findInternalMembership(MembershipDAOHibernate.java:370) at com.atlassian.crowd.dao.membership.MembershipDAOHibernate.isUserDirectMember(MembershipDAOHibernate.java:213) at com.atlassian.crowd.directory.AbstractInternalDirectory.isUserDirectGroupMember(AbstractInternalDirectory.java:893) at com.atlassian.crowd.directory.AbstractInternalDirectory.removeUserFromGroup(AbstractInternalDirectory.java:945) at com.atlassian.crowd.directory.DbCachingRemoteChangeOperations.removeUserMembershipsForGroup(DbCachingRemoteChangeOperations.java:812) at sun.reflect.GeneratedMethodAccessor170.invoke(Unknown Source) {noformat} h5. Scenario 2 - duplicate row in _cwd_user_ The below exception is thrown in the _/home/admin/logs/atlassian-crowd.log_ file: *com.atlassian.crowd.dao.user.UserDAOHibernate.findByExternalId* {noformat} 2016-01-28 17:50:02,838 scheduler_Worker-5 ERROR [atlassian.crowd.directory.DbCachingDirectoryPoller] Error occurred while refreshing the cache for directory [ 425985 ]. org.hibernate.NonUniqueResultException: query did not return a unique result: 2 at org.hibernate.internal.AbstractQueryImpl.uniqueElement(AbstractQueryImpl.java:918) at org.hibernate.internal.CriteriaImpl.uniqueResult(CriteriaImpl.java:396) at com.atlassian.crowd.dao.user.UserDAOHibernate.findByExternalId(UserDAOHibernate.java:213) at com.atlassian.crowd.dao.user.UserDAOHibernate.findByExternalId(UserDAOHibernate.java:55) at com.atlassian.crowd.directory.AbstractInternalDirectory.findUserByExternalId(AbstractInternalDirectory.java:182) at com.atlassian.crowd.directory.DbCachingRemoteChangeOperations.userByExternalIdOrNull(DbCachingRemoteChangeOperations.java:293) at com.atlassian.crowd.directory.DbCachingRemoteChangeOperations.updateUsers(DbCachingRemoteChangeOperations.java:233) at sun.reflect.GeneratedMethodAccessor464.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) {noformat} h3.Workaround A workaround exists for this behavior, but may require direct database modification. Please [contact HipChat Server Support| https://support.atlassian.com/servicedesk/customer/portal/31] for assistance.

    Atlassian JIRA | 10 months ago | Shayne Covey [Atlassian]
    org.hibernate.NonUniqueResultException: query did not return a unique result: 2
  3. 0

    Getting exception when opening Tracker Capture

    GitHub | 2 years ago | adam704a
    org.hibernate.NonUniqueResultException: query did not return a unique result: 2
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    GitHub comment 229#167136122

    GitHub | 11 months ago | ppazos
    org.hibernate.NonUniqueResultException: query did not return a unique result: 2

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.hibernate.NonUniqueResultException

      query did not return a unique result: 2

      at org.hibernate.internal.AbstractQueryImpl.uniqueElement()
    2. Hibernate
      CriteriaImpl.uniqueResult
      1. org.hibernate.internal.AbstractQueryImpl.uniqueElement(AbstractQueryImpl.java:918)
      2. org.hibernate.internal.CriteriaImpl.uniqueResult(CriteriaImpl.java:396)
      2 frames
    3. com.atlassian.crowd
      DbCachingRemoteChangeOperations.updateUsers
      1. com.atlassian.crowd.dao.user.UserDAOHibernate.findByExternalId(UserDAOHibernate.java:213)
      2. com.atlassian.crowd.dao.user.UserDAOHibernate.findByExternalId(UserDAOHibernate.java:55)
      3. com.atlassian.crowd.directory.AbstractInternalDirectory.findUserByExternalId(AbstractInternalDirectory.java:182)
      4. com.atlassian.crowd.directory.DbCachingRemoteChangeOperations.userByExternalIdOrNull(DbCachingRemoteChangeOperations.java:293)
      5. com.atlassian.crowd.directory.DbCachingRemoteChangeOperations.updateUsers(DbCachingRemoteChangeOperations.java:233)
      5 frames
    4. Java RT
      Method.invoke
      1. sun.reflect.GeneratedMethodAccessor464.invoke(Unknown Source)
      2. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      3. java.lang.reflect.Method.invoke(Method.java:606)
      3 frames
    5. Spring AOP
      ReflectiveMethodInvocation.proceed
      1. org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
      2. org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
      3. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
      3 frames