recently I had to alter an EAR in runtime and change the persistance.xml file whithin a JAR inside the EAR. I found the Grobo ant task to be an excellent single line command which does it all.
http://groboutils.sourceforge.net/codecoverage/v2_antdoc_grobo-rezip.html