For some animals that don't have sharp teeth or claws, or other types of classic defense mechanisms, evolution has helped them build a new way to defend themselves. Think nasty, pungent, slimy, and even corrosive barf. Yes, this is a defense mechanism, and it's pretty effective too!
This strange coping strategy is popular among many bird species. For example, vultures are known to induce vomiting as a way to drive away predators. Furthermore, the vulture's emesis is highly acidic, ranging between pH 1 and 2. This is enough to burn some thin-skinned predators if they happen to venture too closely to the vulture.
Other birds that use their stomach content as natural "pepper spray" include herons, gulls, and the European roller.
Interestingly enough, if vomiting is considered a defense mechanism, then some people would also consider human morning sickness during pregnancy a form of defense barfing. Though the act isn't directed at any one predator, per se, the common nausea and vomiting in the early trimesters may be a way to protect the mother-to-be and fetus from potentially toxic foods.