Error: "Could not execute JDBC batch update; SQL [/* Method: unknown */ /* insert com.vmware.vcloud.common.model.UserSessionModel */ insert into user_session " when generating a user API token
search cancel

Error: "Could not execute JDBC batch update; SQL [/* Method: unknown */ /* insert com.vmware.vcloud.common.model.UserSessionModel */ insert into user_session " when generating a user API token

book

Article ID: 383038

calendar_today

Updated On:

Products

VMware Cloud Director

Issue/Introduction

  • When generating a token on VCD tenant portal you get the error:

    Could not execute JDBC batch update; SQL [/* Method: unknown */ /* insert com.vmware.vcloud.common.model.UserSessionModel */ insert into user_session (actor, client_ip_address, date_created, auth_credentials, identifier_token, date_last_accessed, locale, login_org_id, org_member_id, origin_association_id, origin_session_id, refresh_token_id, user_id, session_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; nested exception is org.hibernate.exception.DataException: Could not execute JDBC batch update

  • In /opt/vmware/vcloud-director/logs/vcloud-container-debug.log you see entry similar the one reported below:

    2024-11-20 10:45:04,276 | DEBUG    | pool-jetty-43             | OAuthTokenServiceImpl          | Failed to generate access token | requestId=########-####-####-########afd7,request=POST https://vcloud.example.com/oauth/tenant/ColtenCareDR/token,requestTime=1732099504138,remoteAddress=##.##.##.##:49857,userAgent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ...,accept=application/json;version 38.1
    org.springframework.dao.DataIntegrityViolationException: Could not execute JDBC batch update; SQL [/* Method: unknown */ /* insert com.vmware.vcloud.common.model.UserSessionModel */ insert into user_session (actor, client_ip_address, date_created, auth_credentials, identifier_token, date_last_accessed, locale, login_org_id, org_member_id, origin_association_id, origin_session_id, refresh_token_id, user_id, session_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; nested exception is org.hibernate.exception.DataException: Could not execute JDBC batch update
    [...]
    Caused by: java.sql.BatchUpdateException: Batch entry 0 /* Method: unknown */ /* Method: unknown */ /* insert com.vmware.vcloud.common.model.UserSessionModel */ insert into user_session (actor, client_ip_address, date_created, auth_credentials, identifier_token, date_last_accessed, locale, login_org_id, org_member_id, origin_association_id, origin_session_id, refresh_token_id, user_id, session_id) values (NULL, NULL, '2024-11-20 10:45:04.267+00', NULL, NULL, '2024-11-20 10:45:04.267+00', 'en_GB-OXENDICT', '########-####-####-########847a'::uuid, '########-####-####-########0711'::uuid, NULL, NULL, 'c13ef31f-4802-475f-adf6-2abd7ebe3b5c'::uuid, '########-####-####-########b262'::uuid, ?) was aborted: ERROR: value too long for type character varying(6)  Call getNextException to see other errors in the batch.
    Caused by: org.postgresql.util.PSQLException: ERROR: value too long for type character varying(6)

Environment

VMware Cloud Director 10.x

Cause

The value for the column "locale" in "user_session" table exceed the character limit (6).

Resolution

This will need the modification in the VMware Cloud Director DB, so please make sure to take the  backup of the VMware Cloud Director Database: Backup and Restore of VMware Cloud Director Appliance
Please open a case with Broadcom Support to do the modification in VCD Database. For more information, see Creating and managing Broadcom support cases

Workaround

Change the language of your browser to "English (United Kingdom)"