final File archiveFile = new File(new File(System.getProperty("java.io.tmpdir")), archiveName);
archive.as(ZipExporter.class).exportZip(archiveFile, true);
// Build up the POST form to send to Glassfish
final FormDataMultiPart form = new FormDataMultiPart();
form.getBodyParts().add(new FileDataBodyPart("id", archiveFile));
form.field("contextroot", archiveName.substring(0, archiveName.lastIndexOf(".")), MediaType.TEXT_PLAIN_TYPE);
deploymentName = archiveName.substring(0, archiveName.lastIndexOf("."));
form.field("name", deploymentName, MediaType.TEXT_PLAIN_TYPE);
final String xmlResponse = prepareClient(APPLICATION).type(MediaType.MULTIPART_FORM_DATA_TYPE)
.post(String.class, form);