Can't pin point the exception cause by looking at that small piece of codes... Usually, it is from a loop that does not end properly. As a result, the program keeps creating references/objects in the memory. I used the word references because it includes more than just Java objects.
Stack overflow is usually caused by recursively calling a method from itself. (Too many objects created normally throws a OutOfMemoryError exception, not a stack obverflow.) The error messgae tells you the exact line in your code where it happened. Without that info we can't do anything.