Not every ref points to a commit.  For example in the jgit repository itself the ref refs/tags/spearce-gpg-pub points to a blob.  :-)

This should be wrapped in a try/catch to catch IncorrectObjectTypeException and ignore the error.