use of org.jboss.modules.ModuleLoadException in project wildfly by wildfly.
the class JaxrsScanningProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (!JaxrsDeploymentMarker.isJaxrsDeployment(deploymentUnit)) {
return;
}
final DeploymentUnit parent = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent();
final Map<ModuleIdentifier, ResteasyDeploymentData> deploymentData;
if (deploymentUnit.getParent() == null) {
deploymentData = Collections.synchronizedMap(new HashMap<ModuleIdentifier, ResteasyDeploymentData>());
deploymentUnit.putAttachment(JaxrsAttachments.ADDITIONAL_RESTEASY_DEPLOYMENT_DATA, deploymentData);
} else {
deploymentData = parent.getAttachment(JaxrsAttachments.ADDITIONAL_RESTEASY_DEPLOYMENT_DATA);
}
final ModuleIdentifier moduleIdentifier = deploymentUnit.getAttachment(Attachments.MODULE_IDENTIFIER);
ResteasyDeploymentData resteasyDeploymentData = new ResteasyDeploymentData();
final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
try {
if (warMetaData == null) {
resteasyDeploymentData.setScanAll(true);
scan(deploymentUnit, module.getClassLoader(), resteasyDeploymentData);
deploymentData.put(moduleIdentifier, resteasyDeploymentData);
} else {
scanWebDeployment(deploymentUnit, warMetaData.getMergedJBossWebMetaData(), module.getClassLoader(), resteasyDeploymentData);
scan(deploymentUnit, module.getClassLoader(), resteasyDeploymentData);
}
deploymentUnit.putAttachment(JaxrsAttachments.RESTEASY_DEPLOYMENT_DATA, resteasyDeploymentData);
List<String> rootRestClasses = new ArrayList<>(resteasyDeploymentData.getScannedResourceClasses());
Collections.sort(rootRestClasses);
for (String cls : rootRestClasses) {
addManagement(deploymentUnit, cls);
}
} catch (ModuleLoadException e) {
throw new DeploymentUnitProcessingException(e);
}
}
use of org.jboss.modules.ModuleLoadException in project wildfly by wildfly.
the class JPADependencyProcessor method addHibernate3AdaptorToDeployment.
private void addHibernate3AdaptorToDeployment(final ModuleLoader moduleLoader, final DeploymentUnit deploymentUnit) {
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
try {
final Module module = moduleLoader.loadModule(HIBERNATE_3_PROVIDER);
//use a trick to get to the root of the class loader
final URL url = module.getClassLoader().getResource(HIBERNATE3_PROVIDER_ADAPTOR.replace('.', '/') + ".class");
final URLConnection connection = url.openConnection();
if (!(connection instanceof JarURLConnection)) {
throw JpaLogger.ROOT_LOGGER.invalidUrlConnection("hibernate 3", connection);
}
final JarFile jarFile = ((JarURLConnection) connection).getJarFile();
moduleSpecification.addResourceLoader(ResourceLoaderSpec.createResourceLoaderSpec(ResourceLoaders.createJarResourceLoader("hibernate3integration", jarFile)));
// hack in the dependencies which are part of hibernate3integration
// TODO: do this automatically (adding dependencies found in HIBERNATE_3_PROVIDER).
addDependency(moduleSpecification, moduleLoader, deploymentUnit, JBOSS_AS_NAMING_ID, JBOSS_JANDEX_ID);
} catch (ModuleLoadException e) {
throw JpaLogger.ROOT_LOGGER.cannotLoadModule(e, HIBERNATE_3_PROVIDER, "hibernate 3");
} catch (MalformedURLException e) {
throw JpaLogger.ROOT_LOGGER.cannotAddIntegration(e, "hibernate 3");
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.jboss.modules.ModuleLoadException in project wildfly by wildfly.
the class ExternalTldParsingDeploymentProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
// Skip non web deployments
return;
}
final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
if (warMetaData == null || warMetaData.getMergedJBossWebMetaData() == null) {
return;
}
TldsMetaData tldsMetaData = deploymentUnit.getAttachment(TldsMetaData.ATTACHMENT_KEY);
Map<String, TldMetaData> tlds = tldsMetaData.getTlds();
Set<String> sharedTldUris = new HashSet<>();
for (TldMetaData shared : tldsMetaData.getSharedTlds(deploymentUnit)) {
sharedTldUris.add(shared.getUri());
}
Module module = deploymentUnit.getAttachment(Attachments.MODULE);
try {
Iterator<Resource> resources = module.globResources("META-INF/**.tld");
while (resources.hasNext()) {
final Resource resource = resources.next();
//waste time re-parsing them
if (resource.getURL().toString().contains("com/sun/jsf-impl/main")) {
continue;
}
if (resource.getName().startsWith("META-INF/")) {
if (tlds.containsKey(resource.getName())) {
continue;
}
if (resource.getURL().getProtocol().equals("vfs")) {
continue;
}
final TldMetaData value = parseTLD(resource);
if (sharedTldUris.contains(value.getUri())) {
//don't re-include shared TLD's
continue;
}
String key = "/" + resource.getName();
if (!tlds.containsKey(key)) {
tlds.put(key, value);
}
if (!tlds.containsKey(value.getUri())) {
tlds.put(value.getUri(), value);
}
if (value.getListeners() != null) {
for (ListenerMetaData l : value.getListeners()) {
List<ListenerMetaData> listeners = warMetaData.getMergedJBossWebMetaData().getListeners();
if (listeners == null) {
warMetaData.getMergedJBossWebMetaData().setListeners(listeners = new ArrayList<ListenerMetaData>());
}
listeners.add(l);
}
}
}
}
} catch (ModuleLoadException e) {
throw new DeploymentUnitProcessingException(e);
}
}
use of org.jboss.modules.ModuleLoadException in project wildfly by wildfly.
the class ExpressionFilterDefinition method createHttpHandler.
@Override
public HttpHandler createHttpHandler(Predicate predicate, ModelNode model, HttpHandler next) {
String expression = model.get(EXPRESSION.getName()).asString();
String moduleName = null;
if (model.hasDefined(MODULE.getName())) {
moduleName = model.get(MODULE.getName()).asString();
}
ClassLoader classLoader;
if (moduleName == null) {
classLoader = getClass().getClassLoader();
} else {
try {
ModuleLoader moduleLoader = Module.getBootModuleLoader();
Module filterModule = moduleLoader.loadModule(ModuleIdentifier.fromString(moduleName));
classLoader = filterModule.getClassLoader();
} catch (ModuleLoadException e) {
throw UndertowLogger.ROOT_LOGGER.couldNotLoadHandlerFromModule(expression, moduleName, e);
}
}
List<PredicatedHandler> handlers = PredicatedHandlersParser.parse(expression, classLoader);
UndertowLogger.ROOT_LOGGER.debugf("Creating http handler %s from module %s", expression, moduleName);
if (predicate != null) {
return Handlers.predicate(predicate, Handlers.predicates(handlers, next), next);
} else {
return Handlers.predicates(handlers, next);
}
}
use of org.jboss.modules.ModuleLoadException in project wildfly by wildfly.
the class SharedTldsMetaDataBuilder method init.
private void init() {
try {
ModuleClassLoader jstl = Module.getModuleFromCallerModuleLoader(ModuleIdentifier.create("javax.servlet.jstl.api")).getClassLoader();
for (String tld : JSTL_TAGLIBS) {
InputStream is = jstl.getResourceAsStream("META-INF/" + tld);
if (is != null) {
TldMetaData tldMetaData = parseTLD(tld, is);
jstlTlds.add(tldMetaData);
}
}
} catch (ModuleLoadException e) {
// Ignore
} catch (Exception e) {
// Ignore
}
}
Aggregations