Confluence Sync to JIRA Remote User Dir fails
Asked by Nathan McC:

Trying to get Confluence talking to JIRA remote directory, but the user sync was working is now failing with the following error in the logs. No idea whats causing this. Stash is also setup to use the JIRA user directory and it works fine.

Using Postgres SQL as the database.

|------------------------|-------|
| **Confluence Version** | 5.6.5 |

|                                      Database Information                                      ||
|-----------------------------------------------|-------------------------------------------------|
| **Database name**                             | PostgreSQL                                      |
| **Database version**                          | 9.3.5                                           |
| **Database Dialect**                          | net.sf.hibernate.dialect.PostgreSQLDialect      |
| **Database Driver Name**                      | org.postgresql.Driver                           |
| **Database Driver Version**                   | PostgreSQL 9.2 JDBC4 (build 1002)               |
| **Database Connection URL**                   | jdbc:<postgresql://localhost:5432/confluencedb> |
| **Database Connection Transaction Isolation** | Read committed                                  |
| **Database Latency**                          | 0                                               |

**Error:**

```
2015-02-16 18:08:24,704 ERROR [scheduler_Worker-6] [atlassian.crowd.directory.DbCachingDirectoryPoller] pollChanges Error occurred while refreshing the cache for directory [ 393217 ].
org.springframework.dao.IncorrectResultSizeDataAccessException: query did not return a unique result: 2
 at org.springframework.orm.hibernate.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:590)
 at org.springframework.orm.hibernate.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:353)
 at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:375)
 at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:337)
 at com.atlassian.confluence.user.persistence.dao.hibernate.HibernateConfluenceUserDao.findByUsername(HibernateConfluenceUserDao.java:82)
 at sun.reflect.GeneratedMethodAccessor325.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
 at com.sun.proxy.$Proxy25.findByUsername(Unknown Source)
 at com.atlassian.crowd.embedded.hibernate2.HibernateUserDao.addAll(HibernateUserDao.java:203)
 at com.atlassian.confluence.user.crowd.CachedCrowdUserDao.addAll(CachedCrowdUserDao.java:224)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
 at com.sun.proxy.$Proxy44.addAll(Unknown Source)
 at com.atlassian.crowd.directory.CachingDirectory.addAllUsers(CachingDirectory.java:97)
 at com.atlassian.crowd.directory.DbCachingRemoteChangeOperations.addUsers(DbCachingRemoteChangeOperations.java:181)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
 at com.atlassian.crowd.directory.$Proxy2347.addUsers(Unknown Source)
 at com.atlassian.crowd.directory.DirectoryCacheImplUsingChangeOperations.addOrUpdateCachedUsers(DirectoryCacheImplUsingChangeOperations.java:58)
 at com.atlassian.crowd.directory.ldap.cache.RemoteDirectoryCacheRefresher.synchroniseAllUsers(RemoteDirectoryCacheRefresher.java:68)
 at com.atlassian.crowd.directory.ldap.cache.AbstractCacheRefresher.synchroniseAll(AbstractCacheRefresher.java:78)
 at com.atlassian.crowd.directory.ldap.cache.EventTokenChangedCacheRefresher.synchroniseAll(EventTokenChangedCacheRefresher.java:71)
 at com.atlassian.crowd.directory.DbCachingRemoteDirectory.synchroniseCache(DbCachingRemoteDirectory.java:1008)
 at com.atlassian.crowd.manager.directory.DirectorySynchroniserImpl.synchronise(DirectorySynchroniserImpl.java:75)
 at com.atlassian.crowd.directory.DbCachingDirectoryPoller.pollChanges(DbCachingDirectoryPoller.java:50)
 at com.atlassian.crowd.manager.directory.monitor.poller.DirectoryPollerJobBean.executeInternal(DirectoryPollerJobBean.java:29)
 at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
 at org.quartz.core.JobRunShell.run(JobRunShell.java:199)
 at com.atlassian.confluence.schedule.quartz.ConfluenceQuartzThreadPool$1.run(ConfluenceQuartzThreadPool.java:22)
 at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
```


Answers:
author: Nico Hundling
body: Hi Nathan. Did you manage to resolve this issue? I am experiencing the exact same thing..


author: Volodymyr Krupach
body: Hi Nathan,

```
org.springframework.dao.IncorrectResultSizeDataAccessException: query did not return a unique result: 2
```

Looks like 2 user records are returned where 1 is expected.

This is for MySQL: <https://confluence.atlassian.com/pages/viewpage.action?pageId=254739329> and it says to do not use case insensitive collate. I have no experience with PostgreSQL so I am not sure if that's a case for you.

This article is about removing duplicates: <https://confluence.atlassian.com/display/CONFKB/User+Login+Renders+Error+-+Query+Did+Not+Return+a+Unique+Result>


Tags: confluence-administration

user-directory