Ahh yes......The dreaded bar chord cramp!!! After all the time I've played guitar I still get the occasional "bar chord cramp" when doing a rhythm that uses all bar chords. I remember in the beginning it seemed like my hand was going to fall off!!!
The good news, the cramp should become less painful and less frequent as your experience progresses and your hands become stronger. Doing consistent exercise routines will help to develop hand strength and coordination and help to ease the pain.
They say "No pain no Gain" I guess this expression was made by a guitarist playing bar chords.