Its tough to give any advice given the code posted and a lack of any stack trace that references said code. Recommend you post an SSCCE which clearly demonstrates the problem.