Thanks for your suggestion. Its causing for most of the pdf's. I had tried setting tags on other pdf's before but they did not throw any exception. There is a property "jcr:isCheckedOut" set to false on these pdfs. I am not sure how and when this gets set to false. Then there are others set to true.
I tried using versionManager to checkout this resource before tagging, but I am not able to get the version manager working.