Question

How does this reaction form when its not favored?

I thought that carboxylic acids were more reactive than amides so how can this reaction occur?enter image description here