try {
Archivist archivist = ArchivistFactory.getArchivistForType(request.getType().getModuleType());
archivist.setAnnotationProcessingRequested(true);
String appDir = request.getDeployedDirectory().getAbsolutePath();
FileArchive in = new FileArchive();
in.open(appDir);
if (request.isVerifying()) {
archivist.setRuntimeXMLValidation(true);
archivist.setRuntimeXMLValidationLevel("full");
}
if (validationLevel.equals("none")) {
archivist.setXMLValidation(false);
} else {
archivist.setXMLValidation(true);
archivist.setXMLValidationLevel(validationLevel);
}
//Note in copying of deployment plan to the portable archive,
//we should make sure the manifest in the deployment plan jar
//file does not overwrite the one in the original archive
//NOTE. We are not checking the size of the deploymentPlan file
//here, since it looks like on windows the size of this tmp
//file is always zero when we attempt to query its size.
//Instead, we are making sure the 0 length deployment plan is
//not uploaded in DeploymentFacility implementation.
if (request.getDeploymentPlan() != null) {
DeploymentPlanArchive dpa = new DeploymentPlanArchive();
dpa.open(request.getDeploymentPlan().getAbsolutePath());
if (request.isApplication()) {
ApplicationArchivist aa = (ApplicationArchivist)archivist;
aa.copyInto(request.getDescriptor(), dpa, in, false);
} else {
archivist.copyInto(dpa, in, false);
}
}
// now let's create a class loader for this module
// parent class loader (from admin server)
ClassLoader parent =
(Boolean.getBoolean(com.sun.enterprise.server.PELaunch.USE_NEW_CLASSLOADER_PROPERTY))
? com.sun.enterprise.server.PELaunch.getAppServerChain()
: ClassLoader.getSystemClassLoader();
// sets the parent class loader and class paths in deployment req
DeploymentUtils.setParentClassLoader(parent, getManager(), request);
// parent class paths for this deployment request
List allClassPaths = request.getParentClasspath();
// parent class loader for this deployment request
ClassLoader sharedClassLoader = request.getParentClassLoader();
List moduleClasspath = getModuleClasspath(archivist, in);
// add the libraries from --libraries option to module classpath
String libs = request.getLibraries();
URL[] deployTimeLibraries =
ASClassLoaderUtil.getLibraries(libs);
if (deployTimeLibraries != null) {
for (int i=0; i< deployTimeLibraries.length; i++) {
String libPath = new File(
deployTimeLibraries[i].toURI()).getPath();
moduleClasspath.add(libPath);
}
}
request.setModuleClasspath(moduleClasspath);
allClassPaths.addAll(moduleClasspath);
final ClassLoader ejbClassLoader = DeploymentUtils.getClassLoader(
moduleClasspath, sharedClassLoader, null);
// sets the ejb class loader & class paths - used during jspc
request.setEjbClassLoader(ejbClassLoader);
request.setCompleteClasspath(allClassPaths);
// set classloader used for annotation processing
archivist.setClassLoader(ejbClassLoader);
// set the context classloader to ejbClassLoader for DD
// processing
ClassLoader origContextClassLoader =
Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(ejbClassLoader);
Application application = request.getDescriptor();
if (application!=null && ModuleType.EAR.equals(archivist.getModuleType())) {
archivist.readPersistenceDeploymentDescriptors(in, application);
// Now process standard DDs, do this before runtime DDs
archivist.setHandleRuntimeInfo(false);
boolean modulesReadSuccess = ((ApplicationArchivist) archivist).readModulesDescriptors(application, in);
if (modulesReadSuccess ) {
// now process runtime DDs
archivist.setHandleRuntimeInfo(true);
archivist.readRuntimeDeploymentDescriptor(in, application);
} else {
// it failed reading sub modules, I null our application which will trigger
// deployment failure handling
application=null;
}
} else {
application = ApplicationArchivist.openArchive(archivist, in, true);
}
if (application==null) {
throw new IASDeploymentException(localStrings.getString(
"enterprise.deployment.backend.error_loading_dds",
new Object[] { request.getName(), " " }));
}
application.setRegistrationName(request.getName());
application.setClassLoader(ejbClassLoader);
archivist.setDescriptor(application);
// let's check for optional dependencies
if (!archivist.performOptionalPkgDependenciesCheck(in)) {
throw new IASDeploymentException(localStrings.getString("enterprise.deployment.backend.archive_opt_dep_not_satisfied", new Object[] {in.getArchiveUri()}));
}
archivist.validate(ejbClassLoader);
if (!application.getWebServiceDescriptors().isEmpty()) {