1 Kings 2:29 & 30

"King Solomon was told that Joab had fled to the tent of the Lord and was beside the altar. Then Solomon ordered Benaiah son of Jehoiada, 'Go, strike him down!' So Benaiah entered the tent of the Lord and said to Joab, 'The king says, "Come out!"' But he answered, 'No, I will die here.' Benaiah reported to the king, 'This is how Joab answered me.'" NIV translation

Why had Solomon allowed Adonijah to live when he plead for mercy but now ordered the death of Joab? As we saw in verse 6, David had told Solomon that he was to die.

1 Kings 2:31 - 33

"Then the king commanded Benaiah, 'Do as he says. Strike him down and bury him, and so clear me and my father's house of the guilt of the innocent blood that Joab shed. The Lord will repay him for the blood he shed, because without the knowledge of my father David he attacked two men and killed them with the sword. Both of them - Abner son of Ner, commander of Israel's army, and Amasa son of Jether, commander of Judah's army - were better men and more upright than he. May the guilt of their blood rest on the head of Joab and his descendants forever. But on David and his descendants, his house and his throne, may there be the Lord's peace forever.'" NIV translation

Joab had killed two men in order to take their jobs as head of the army. He did this without the knowledge of the king and showed them no mercy. According to the law, the penalty for him was death. As Jesus said in the Sermon on the Mount, it is those who show mercy to others that receive mercy from God. 

1 Kings 2:34 & 35

"So Benaiah son of Jehoiada went up and struck down Joab and killed him, and he was buried on his own land in the desert. The king put Benaiah son of Jehoiada over the army in Joab's position and replaced Abiathar with Zadok the priest." NIV translation

The sentence of the king was carried out and we see that Joab was buried in the desert. Throughout the Bible, the desert is associated with times of trials and testing. We see that Joab had failed his trial as he had appeared to be serving the king but was out for himself. We all go through trials (pass through the desert) but it is not good to be buried there. Like Joab, there are many today who will say they are serving the King of Kings but in reality are out for what they can get for themselves. As we see with Joab and Abiathar, they will be found out and will end up being buried in the desert.