Where does it hang? Do you get exceptions? Did you add print lines to see where it might hang?
...