org.springframework.dao.IncorrectResultSizeDataAccessException: query did not return a unique result: 2 @400000004e166d143482489c at org.springframework.orm.hibernate.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:590) @400000004e166d143482600c at org.springframework.orm.hibernate.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:353) @400000004e166d14348263f4 at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:375) @400000004e166d14348267dc at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:337) @400000004e166d1434826bc4 at com.atlassian.bamboo.plan.PlanHibernateDao.getPlanByKey(PlanHibernateDao.java:43)

Atlassian JIRA | Tim Moore [Atlassian] | 5 years ago
  1. 0

    Looks like a double-post of a create plan form resulted in duplicate plan key creation: {noformat} bamboo=# select build_id, buildkey from build; build_id | buildkey ----------+---------- 393217 | TRUNK 1507329 | JSTMVN 1507330 | JSTMVN 393218 | JOB1 {noformat} Excerpt from the Bamboo logs at that time: {noformat} @400000004e166cf406b6c1f4 2011-07-07 21:35:22,112 INFO [TP-Processor15] [AccessLogFilter] sysadmin POST https://sdog.jira.com/builds/build/admin/create/createPlan.action 103093kb @400000004e166d0d0c95cb4c 2011-07-07 21:35:47,211 INFO [TP-Processor17] [AccessLogFilter] sysadmin POST https://sdog.jira.com/builds/build/admin/create/createPlan.action 114482kb @400000004e166d1429151cdc 2011-07-07 21:35:54,685 INFO [TP-Processor15] [PlanCreationTemplate] Creating plan with key: JSTDEV-JSTMVN @400000004e166d14301380b4 2011-07-07 21:35:54,803 INFO [TP-Processor15] [PlanCreationTemplate] New build created with key JSTDEV-JSTMVN @400000004e166d1432779bec 2011-07-07 21:35:54,844 INFO [TP-Processor17] [PlanCreationTemplate] Creating plan with key: JSTDEV-JSTMVN @400000004e166d1434823ce4 2011-07-07 21:35:54,852 ERROR [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-6] [ChainExecutionManagerImpl] Could not start executing Plan 'JSTDEV-JSTMVN' as the plan did not have any stages defined @400000004e166d14348244b4 2011-07-07 21:35:54,878 ERROR [TP-Processor17] [FiveOhOh] 500 Exception was thrown. @400000004e166d143482489c org.springframework.dao.IncorrectResultSizeDataAccessException: query did not return a unique result: 2 @400000004e166d143482489c at org.springframework.orm.hibernate.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:590) @400000004e166d143482600c at org.springframework.orm.hibernate.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:353) @400000004e166d14348263f4 at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:375) @400000004e166d14348267dc at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:337) @400000004e166d1434826bc4 at com.atlassian.bamboo.plan.PlanHibernateDao.getPlanByKey(PlanHibernateDao.java:43) @400000004e166d1434826fac at sun.reflect.GeneratedMethodAccessor225.invoke(Unknown Source) @400000004e166d1434826fac at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) @400000004e166d143482871c at java.lang.reflect.Method.invoke(Method.java:597) @400000004e166d1434828b04 at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304) @400000004e166d1434828b04 at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) @400000004e166d1434828eec at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) @400000004e166d14348296bc at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) @400000004e166d14348296bc at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) @400000004e166d1434829aa4 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) @400000004e166d1434829e8c at $Proxy7.getPlanByKey(Unknown Source) @400000004e166d1434829e8c at com.atlassian.bamboo.plan.PlanManagerImpl.getPlanByKey(PlanManagerImpl.java:91) @400000004e166d143482a274 at com.atlassian.bamboo.plan.PlanManagerImpl.getPlanByKey(PlanManagerImpl.java:85) {noformat} This completely breaks Bamboo. It can no longer even start up without throwing the {{IncorrectResultSizeDataAccessException}}. Ideally, the uniqueness of this key should be enforced via a database constraint.

    Atlassian JIRA | 5 years ago | Tim Moore [Atlassian]
    org.springframework.dao.IncorrectResultSizeDataAccessException: query did not return a unique result: 2 @400000004e166d143482489c at org.springframework.orm.hibernate.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:590) @400000004e166d143482600c at org.springframework.orm.hibernate.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:353) @400000004e166d14348263f4 at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:375) @400000004e166d14348267dc at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:337) @400000004e166d1434826bc4 at com.atlassian.bamboo.plan.PlanHibernateDao.getPlanByKey(PlanHibernateDao.java:43)
  2. 0

    Looks like a double-post of a create plan form resulted in duplicate plan key creation: {noformat} bamboo=# select build_id, buildkey from build; build_id | buildkey ----------+---------- 393217 | TRUNK 1507329 | JSTMVN 1507330 | JSTMVN 393218 | JOB1 {noformat} Excerpt from the Bamboo logs at that time: {noformat} @400000004e166cf406b6c1f4 2011-07-07 21:35:22,112 INFO [TP-Processor15] [AccessLogFilter] sysadmin POST https://sdog.jira.com/builds/build/admin/create/createPlan.action 103093kb @400000004e166d0d0c95cb4c 2011-07-07 21:35:47,211 INFO [TP-Processor17] [AccessLogFilter] sysadmin POST https://sdog.jira.com/builds/build/admin/create/createPlan.action 114482kb @400000004e166d1429151cdc 2011-07-07 21:35:54,685 INFO [TP-Processor15] [PlanCreationTemplate] Creating plan with key: JSTDEV-JSTMVN @400000004e166d14301380b4 2011-07-07 21:35:54,803 INFO [TP-Processor15] [PlanCreationTemplate] New build created with key JSTDEV-JSTMVN @400000004e166d1432779bec 2011-07-07 21:35:54,844 INFO [TP-Processor17] [PlanCreationTemplate] Creating plan with key: JSTDEV-JSTMVN @400000004e166d1434823ce4 2011-07-07 21:35:54,852 ERROR [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-6] [ChainExecutionManagerImpl] Could not start executing Plan 'JSTDEV-JSTMVN' as the plan did not have any stages defined @400000004e166d14348244b4 2011-07-07 21:35:54,878 ERROR [TP-Processor17] [FiveOhOh] 500 Exception was thrown. @400000004e166d143482489c org.springframework.dao.IncorrectResultSizeDataAccessException: query did not return a unique result: 2 @400000004e166d143482489c at org.springframework.orm.hibernate.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:590) @400000004e166d143482600c at org.springframework.orm.hibernate.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:353) @400000004e166d14348263f4 at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:375) @400000004e166d14348267dc at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:337) @400000004e166d1434826bc4 at com.atlassian.bamboo.plan.PlanHibernateDao.getPlanByKey(PlanHibernateDao.java:43) @400000004e166d1434826fac at sun.reflect.GeneratedMethodAccessor225.invoke(Unknown Source) @400000004e166d1434826fac at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) @400000004e166d143482871c at java.lang.reflect.Method.invoke(Method.java:597) @400000004e166d1434828b04 at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304) @400000004e166d1434828b04 at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) @400000004e166d1434828eec at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) @400000004e166d14348296bc at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) @400000004e166d14348296bc at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) @400000004e166d1434829aa4 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) @400000004e166d1434829e8c at $Proxy7.getPlanByKey(Unknown Source) @400000004e166d1434829e8c at com.atlassian.bamboo.plan.PlanManagerImpl.getPlanByKey(PlanManagerImpl.java:91) @400000004e166d143482a274 at com.atlassian.bamboo.plan.PlanManagerImpl.getPlanByKey(PlanManagerImpl.java:85) {noformat} This completely breaks Bamboo. It can no longer even start up without throwing the {{IncorrectResultSizeDataAccessException}}. Ideally, the uniqueness of this key should be enforced via a database constraint.

    Atlassian JIRA | 5 years ago | Tim Moore [Atlassian]
    org.springframework.dao.IncorrectResultSizeDataAccessException: query did not return a unique result: 2 @400000004e166d143482489c at org.springframework.orm.hibernate.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:590) @400000004e166d143482600c at org.springframework.orm.hibernate.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:353) @400000004e166d14348263f4 at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:375) @400000004e166d14348267dc at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:337) @400000004e166d1434826bc4 at com.atlassian.bamboo.plan.PlanHibernateDao.getPlanByKey(PlanHibernateDao.java:43)
  3. 0

    There are two elastic images called "EBS x86_64 (linux)", with AMIs ami-270b444e and ami-4488f72d. When you go to change anything in one of those two (say, changing the instance size), upon clicking save you're greeted with this stack trace: {code:none} 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.bamboo.agent.elastic.server.ElasticImageConfigurationHibernateDao.getElasticImageConfigurationByName(ElasticImageConfigurationHibernateDao.java:187) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 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:304) 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 $Proxy98.getElasticImageConfigurationByName(Unknown Source) at com.atlassian.bamboo.agent.elastic.server.ElasticImageConfigurationAccessorImpl.getElasticImageConfigurationByName(ElasticImageConfigurationAccessorImpl.java:52) at com.atlassian.bamboo.agent.elastic.server.ElasticImageConfigurationManagerImpl.getElasticImageConfigurationByName(ElasticImageConfigurationManagerImpl.java:69) at com.atlassian.bamboo.ww2.actions.admin.elastic.ConfigureElasticImageConfiguration.validate(ConfigureElasticImageConfiguration.java:380) at com.opensymphony.xwork2.validator.ValidationInterceptor.doBeforeInvocation(ValidationInterceptor.java:251) at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263) at com.atlassian.bamboo.ww2.interceptors.BambooValidationInterceptor.validate(BambooValidationInterceptor.java:48) at com.atlassian.bamboo.ww2.interceptors.BambooValidationInterceptor.access$000(BambooValidationInterceptor.java:12) at com.atlassian.bamboo.ww2.interceptors.BambooValidationInterceptor$1.call(BambooValidationInterceptor.java:28) at com.atlassian.bamboo.ww2.interceptors.BambooValidationInterceptor$1.call(BambooValidationInterceptor.java:24) at com.atlassian.bamboo.util.BambooProfilingUtils.withUtilTimerStack(BambooProfilingUtils.java:49) at com.atlassian.bamboo.ww2.interceptors.BambooValidationInterceptor.doIntercept(BambooValidationInterceptor.java:23) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) [...] {code} Ideally Bamboo shouldn't be relying on the name alone to identify the images. :( *Workaround* # Edit one of the two affected AMI's (Ubuntu: EBS x86_64 (linux) or Amazon Linux EBS x86_64 (linux) ) # Change only the name of the AMI (EBS x86_64 (linux) to EBS_x86_64 (linux) for example) # Save the Image configuration

    Atlassian JIRA | 3 years ago | Nick Mason [Atlassian]
    org.springframework.dao.IncorrectResultSizeDataAccessException: query did not return a unique result: 2
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Sometimes, when renaming users in a external directory, a new user is created, instead of updating the current one. This causes a duplicity in the pair external_id and directory_id which cause an exception when calling the method {{com.atlassian.confluence.user.crowd.CachedCrowdUserDao.findByExternalId}} which is used during authentication and synchronization of the external directory. The error resulting from that operation is: {noformat}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.crowd.embedded.hibernate2.HibernateUserDao.internalFindUserByExternalId(HibernateUserDao.java:501) at com.atlassian.crowd.embedded.hibernate2.HibernateUserDao.internalFindByExternalId(HibernateUserDao.java:473) at com.atlassian.crowd.embedded.hibernate2.HibernateUserDao.findByExternalId(HibernateUserDao.java:449) at com.atlassian.confluence.user.crowd.CachedCrowdUserDao.findByExternalId(CachedCrowdUserDao.java:164) ...{noformat} This affects embedded Crowd so other Atlassian applications (Confluence, JIRA,...) may also have this problem.

    Atlassian JIRA | 2 years ago | Alejandro Conde Carrillo
    org.springframework.dao.IncorrectResultSizeDataAccessException: query did not return a unique result: 2
  6. 0

    In the table cwd_user, there should be no rows where the _external_id_ is repeated for the same _directory_id_. Said in another way, the _external_id_ should be unique for the same _directory_id_. To avoid this from causing problems, we should add a unique constraint at a database level in the table _cwd_user_. When two users share _external_id_ and _directory_id_, the user is not able to login or update new information from the external user directory. Those actions will fail with the following error: {noformat}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.crowd.embedded.hibernate2.HibernateUserDao.internalFindUserByExternalId(HibernateUserDao.java:501) at com.atlassian.crowd.embedded.hibernate2.HibernateUserDao.internalFindByExternalId(HibernateUserDao.java:473) at com.atlassian.crowd.embedded.hibernate2.HibernateUserDao.findByExternalId(HibernateUserDao.java:449) at com.atlassian.confluence.user.crowd.CachedCrowdUserDao.findByExternalId(CachedCrowdUserDao.java:164) ...{noformat} This also affects embedded Crowd.

    Atlassian JIRA | 3 years ago | Alex Conde [Atlassian]
    org.springframework.dao.IncorrectResultSizeDataAccessException: 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.springframework.dao.IncorrectResultSizeDataAccessException

      query did not return a unique result: 2 @400000004e166d143482489c at org.springframework.orm.hibernate.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:590) @400000004e166d143482600c at org.springframework.orm.hibernate.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:353) @400000004e166d14348263f4 at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:375) @400000004e166d14348267dc at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:337) @400000004e166d1434826bc4 at com.atlassian.bamboo.plan.PlanHibernateDao.getPlanByKey(PlanHibernateDao.java:43)

      at sun.reflect.GeneratedMethodAccessor225.invoke()
    2. Java RT
      DelegatingMethodAccessorImpl.invoke
      1. sun.reflect.GeneratedMethodAccessor225.invoke(Unknown Source)
      2. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      2 frames