In addition to Somatic component, if the spell has material component, you need one free hand. This is not truly clear in the rulebook. But reasonable to think so and FAQ supports for it.
There are several options for a cleric.
1. Using a light shield.
A cleric move his weapon to his shield hand as a move action and then cast a spell. Retrieving the weapon to his weapon arm is another move action. Again, according to FAQ.
2. Using a buckler.
You can use your hand with buckler for performing somatic component. But if you do so, you lose that buckler's AC bonus until next turn. Again, according to FAQ.
3. Using a two-handed weapon. Or use a one-handed weapon in two hands.
It is also not clear in the rule book. But many DMs consider removing a hand from the grip of a two-handed weapon is a free action. And many DMs also consider putting that hand back on the grip is also a free action. There are some DMs who has objection, though.
4. Have more than 3 arms.
Like Thri-Kreen.