This article intends to provide resolution for deploying template from subscribed content library with the following symptoms,
Failed to deploy OVF package. Cause: A general system error occurred: Provider method implementation threw unexpected exception: query did not return a unique result: 2; nested exception is javax.persistence.NonUniqueResultException: query did not return a unique result: 2" .YYYY-MM-DDThh:mm:ss | ERROR | null | cls-simple-activity-# | SimpleActivityWorker | Exception will not be handled by activity ############ (handle=11###-9##e-4##b-a##b-6f########56, entityId=<entity_id>): query did not return a unique result: 2; nested exception is javax.persistence.NonUniqueResultException: query did not return a unique result: 2org.springframework.dao.IncorrectResultSizeDataAccessException: query did not return a unique result: 2; nested exception is javax.persistence.NonUniqueResultException: query did not return a unique result: 2
Duplicate entries for one or more content library items in vCenter's Database.
To resolve this issue, the duplicate entries for content library items need to be removed
Before applying the steps below, please take a backup or an offline-snapshot (in powered-off state) of the vCenter Server Appliance . If the vCenter is part of a Linked Mode replication setup, please refer to VMware vCenter in Enhanced Linked Mode pre-changes snapshot (online or offline) best practice
We strongly recommend contacting Broadcom technical support, as deleting incorrect entries may corrupt the database and make vCenter inaccessible.
service-control --stop vmware-content-library
service-control --stop vpxd
/opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres
entity ID observed from cls.log and run the below query to verify duplicate entriesSELECT * FROM cl_libraryitem_certificate_verification certInfo WHERE certInfo.itemId = '<entity_id>';
cl_libraryitem_certificate_verification and there are other tables as well like cl_libraryitemversion, cl_libraryitem etc. Deleting items this way can leave the entries in inconsistent state.DELETE FROM cl_libraryitem_certificate_verification cert_ver_old USING (SELECT MIN(ctid) as ctid, itemId FROM cl_libraryitem_certificate_verification GROUP BY itemId HAVING COUNT(*) > 1) cert_ver_new WHERE cert_ver_new.itemId = cert_ver_old.itemId AND cert_ver_new.ctid <> cert_ver_old.ctid; Step 4.Quit the VCDB using below command: \q
Start the stopped vCenter services by using the command: service-control --start && vmware-content-libraryservice-control --start vpxd
Re-sync the OVF template within the content library.
Once the sync is finished, re-attempt the OVF deployment.