Without looking at your work, I might suggest that youuse a deployment package such as ant.it can take care of alot of the problems you arehaving.