Where is the sparkContext object defined, is it inside the main function?
I too faced the same problem, the mistake which i did was i initiated the sparkContext outside the main function and inside the class.
When I initiated it inside the main function, it worked fine.