Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-22469

Editing "User Directories" configuration is not possible for ORACLE DB user due to DataIntegrityViolationException

    XMLWordPrintable

Details

    Description

      Summary of The Bug

      ORACLE database users (10/11) could not modify their user directories, due to UNIQUE CONSTRAINT ERROR thrown by Confluence:

      2011-05-07 00:39:13,768 ERROR [http-8353-1] [sf.hibernate.util.JDBCExceptionReporter] logExceptions ORA-00001: unique constraint (SEPCONFTWO.SYS_C004591) violated
      
       -- referer: http://localhost:8353/plugins/servlet/embedded-crowd/configure/ldap/ | url: /plugins/servlet/embedded-crowd/configure/ldap/ | userName: admin
      2011-05-07 00:39:13,770 ERROR [http-8353-1] [sf.hibernate.impl.SessionImpl] execute Could not synchronize database state with session
       -- referer: http://localhost:8353/plugins/servlet/embedded-crowd/configure/ldap/ | url: /plugins/servlet/embedded-crowd/configure/ldap/ | userName: admin
      2011-05-07 00:39:13,841 ERROR [http-8353-1] [atlassian.plugin.servlet.ServletModuleContainerServlet] service Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: Hibernate operation: could not insert collection rows: [com.atlassian.crowd.model.directory.DirectoryImpl.attributes#327682]; SQL []; ORA-00001: unique constraint (SEPCONFTWO.SYS_C004591) violated
      ; nested exception is java.sql.SQLException: ORA-00001: unique constraint (SEPCONFTWO.SYS_C004591) violated
      
       -- referer: http://localhost:8353/plugins/servlet/embedded-crowd/configure/ldap/ | url: /plugins/servlet/embedded-crowd/configure/ldap/ | userName: admin
      org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: Hibernate operation: could not insert collection rows: [com.atlassian.crowd.model.directory.DirectoryImpl.attributes#327682]; SQL []; ORA-00001: unique constraint (SEPCONFTWO.SYS_C004591) violated
      ; nested exception is java.sql.SQLException: ORA-00001: unique constraint (SEPCONFTWO.SYS_C004591) violated
      

      Steps to reproduce

      1. Install Confluence 3.5.x instance with ORACLE (10/11) database
      2. Create a new LDAP Directory, test and save it.
      3. Edit the directory (modify some of the LDAP attributes, eg. User Schema Settings > User Object Filter). Test and save. A System Error will be thrown.

      Fix

      Use the attached patch to resolve the issue. To install the patch, extract it to your <confluence-install-dir>/confluence/WEB-INF/classes directory. Ensure that the following files are created:

      1. com/atlassian/crowd/embedded/hibernate2/HibernateDirectoryDao$1.class
      2. com/atlassian/crowd/embedded/hibernate2/HibernateDirectoryDao$2.class
      3. com/atlassian/crowd/embedded/hibernate2/HibernateDirectoryDao.class
        Then, restart Confluence.

      Cause

      This occurs due to Oracle treating blank strings and null values as equal, and Hibernate 2 not being smart enough to realise that the same entry already exists, because in Java, a blank string is not equal to a null. This causes Hibernate to try to insert a row that already exists.

      MySQL DEBUG log
      2011-05-04 18:46:16,007 DEBUG [QuartzScheduler_Worker-2] [net.sf.hibernate.SQL] log select attributes0_.directory_id as director1___, attributes0_.attribute_value as attribut2___, attributes0_.attribute_name as attribut3___ from cwd_directory_attribute attributes0_ where attributes0_.directory_id=?
      2011-05-04 18:46:16,017 DEBUG [QuartzScheduler_Worker-2] [net.sf.hibernate.SQL] log update cwd_directory set directory_name=?, lower_directory_name=?, created_date=?, updated_date=?, active=?, description=?, impl_class=?, lower_impl_class=?, directory_type=? where id=?
      2011-05-04 18:46:16,018 DEBUG [QuartzScheduler_Worker-2] [net.sf.hibernate.SQL] log delete from cwd_directory_attribute where directory_id=? and attribute_name=?
      2011-05-04 18:46:16,018 DEBUG [QuartzScheduler_Worker-2] [net.sf.hibernate.SQL] log update cwd_directory_attribute set attribute_value=? where directory_id=? and attribute_name=?
      
      ORACLE DEBUG log
      2011-05-06 23:58:51,560 DEBUG [http-8080-5] [net.sf.hibernate.SQL] log update cwd_directory set directory_name=?, lower_directory_name=?, created_date=?, updated_date=?, active=?, description=?, impl_class=?, lower_impl_class=?, directory_type=? where id=?
      2011-05-06 23:58:51,563 DEBUG [http-8080-5] [net.sf.hibernate.SQL] log delete from cwd_directory_operation where directory_id=?
      2011-05-06 23:58:51,576 DEBUG [http-8080-5] [net.sf.hibernate.SQL] log delete from cwd_directory_attribute where directory_id=? and attribute_name=?
      2011-05-06 23:58:51,579 DEBUG [http-8080-5] [net.sf.hibernate.SQL] log update cwd_directory_attribute set attribute_value=? where directory_id=? and attribute_name=?
      2011-05-06 23:58:51,581 DEBUG [http-8080-5] [net.sf.hibernate.SQL] log insert into cwd_directory_attribute (directory_id, attribute_name, attribute_value) values (?, ?, ?)
      2011-05-06 23:58:51,622 ERROR [http-8080-5] [sf.hibernate.util.JDBCExceptionReporter] logExceptions ORA-00001: unique constraint (SEPCONFONE.SYS_C004301) violated
      

      Attachments

        Issue Links

          Activity

            People

              nbhawnani Niraj Bhawnani
              scahyadiputra Septa Cahyadiputra (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 4h
                  4h
                  Remaining:
                  Remaining Estimate - 4h
                  4h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified