Uriah was a loyal soldier and trusted David through all his campaigns and persecutions by Saul.
He had no idea he was going to be betrayed by those he loved.
Joab made sure of that...............
I think the only way Joab stayed on as general was because he had the loyalty of the common soldiers. Joab and David despised each other, even more so after the debacle with Absolom. Joab had all the information to blackmail David as well, which is why David never sacked him after the murders of Abner and Amasa.