}
module.setEarContext(moduleContext);
module.setRootEarContext(earContext);
try {
ClassPathList manifestcp = new ClassPathList();
// add the warfile's content to the configuration
JarFile warFile = module.getModuleFile();
Enumeration<JarEntry> entries = warFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
URI targetPath = new URI(null, entry.getName(), null);
if (entry.getName().equals("WEB-INF/web.xml")) {
moduleContext.addFile(targetPath, module.getOriginalSpecDD());
} else if (entry.getName().startsWith("WEB-INF/lib") && entry.getName().endsWith(".jar")) {
moduleContext.addInclude(targetPath, warFile, entry);
manifestcp.add(entry.getName());
} else {
moduleContext.addFile(targetPath, warFile, entry);
}
}
//always add WEB-INF/classes to the classpath regardless of whether
//any classes exist
moduleContext.getConfiguration().addToClassPath("WEB-INF/classes/");
manifestcp.add("WEB-INF/classes/");
// add the manifest classpath entries declared in the war to the class loader
// we have to explicitly add these since we are unpacking the web module
// and the url class loader will not pick up a manifest from an unpacked dir
moduleContext.addManifestClassPath(warFile, RELATIVE_MODULE_BASE_URI);
moduleContext.getGeneralData().put(ClassPathList.class, manifestcp);