OutputStream outputStream = new FileOutputStream(webAppsDir + webModule + File.separator + "WEB-INF" + File.separator + "web.xml");
Writer writer = new OutputStreamWriter(outputStream, "utf-8");
Serializer serializer = new XMLSerializer(writer, of);
try {
WebApplicationMarshaller wam = new WebApplicationMarshaller();
wam.init(webApplicationDefinition, serializer);
wam.marshall();
} catch (Exception e) {
writer.close();
e.printStackTrace(System.out);
throw new Exception();
}