Created On:  02 February 2012

Problem:

Why does executing the CreateUser method from the SCTM Web Service API raise a Java NULL exception error?

Resolution:

When executing the CreateUser method against SilkCentral Test Manager 2011 (SCTM); for example like so:

---------------------------------------------------------------
    Sub Main()

        Dim mainEntities As New MainEntitiesService
      
        Dim user1 As New UserDetails

        'user details
        user1.assignedProjects = {0}
        user1.dateFormat = "EEE, MMM dd, yyyy - hh:mm:ss a"
        user1.shortDateFormat = "MM/dd/yyyy, hh:mm a"
        user1.eMail = "
name@company.com"
        user1.roleId = 1
        user1.login = "WEBSERVICE"
        user1.firstName = "WEB"
        user1.name = "SERVICE"
        user1.description = "blah"
        user1.pageRefreshTime = 10
        user1.isLocked = False
        user1.firstDayOfWeek = 2
        user1.separatorString = ";"
        user1.timeZoneId = "America" + "/" + "New_York"

        Dim sessionID As Long
        sessionID = sccSystem.logonUser("admin", "admin")
    
        mainEntities.createUser(sessionID, user1)

---------------------------------------------------------------

You will encounter the following error message listed below:

java.lang.RuntimeException: com.segue.scc.webservice.exceptions.InternalException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_SCC_UserGroupRoles_UserGroup". The conflict occurred in database "SCTMVM", table "dbo.SCC_UserGroups", column 'GroupID_pk'.
      at es.borland.admin.tools.SCTMManager.createUser(SCTMManager.java:177)
      at es.borland.admin.tools.command.UserImporterMain$2.actionPerformed(UserImporterMain.java:110)


However it is important to note that the error will only ever occur if the 'Default User Group' has been deleted in SCTM prior to executing the ceateUser method.

NB. You can check if the 'Default User Group' has been removed in SCTM by going to ‘ Administration | User Management | Groups’.

 

To resolve the error you will have to add a UserGroup with  ID = 1; this can be done by executing the following SQL statements against the appropriate SCTM databases

For SQL Server, execute:

SET IDENTITY_INSERT SCC_UserGroups ON;
INSERT INTO SCC_UserGroups (GroupID_pk, GroupName, IsLocked, Description, CreatedAt,
CreatedBy, ModifyCounter)
VALUES(1, 'Default user group', 0, 'Default user group', GETDATE(), 'admin', 1)
SET IDENTITY_INSERT SCC_UserGroups OFF;


For Oracle, execute:

INSERT INTO SCC_UserGroups (GroupID_pk, GroupName, IsLocked, Description, CreatedAt,
CreatedBy, ModifyCounter) 
VALUES(1, 'Default user group', 0, 'Default user group', sysdate, 'admin', 1) 
 
(you only need the insert statement and use sysdate instead of GETDATE)

Incident #2553069