use of org.jboss.modules.ModuleLoadException in project wildfly by wildfly.
the class NamingBindingAdd method createObjectFactory.
private ObjectFactory createObjectFactory(OperationContext context, ModelNode model) throws OperationFailedException {
final ModuleIdentifier moduleID = ModuleIdentifier.fromString(NamingBindingResourceDefinition.MODULE.resolveModelAttribute(context, model).asString());
final String className = NamingBindingResourceDefinition.CLASS.resolveModelAttribute(context, model).asString();
final Module module;
try {
module = Module.getBootModuleLoader().loadModule(moduleID);
} catch (ModuleNotFoundException e) {
throw NamingLogger.ROOT_LOGGER.moduleNotFound(moduleID, e.getMessage());
} catch (ModuleLoadException e) {
throw NamingLogger.ROOT_LOGGER.couldNotLoadModule(moduleID);
}
final ObjectFactory objectFactoryClassInstance;
final ClassLoader cl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
try {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(module.getClassLoader());
final Class<?> clazz = module.getClassLoader().loadClass(className);
objectFactoryClassInstance = (ObjectFactory) clazz.newInstance();
} catch (ClassNotFoundException e) {
throw NamingLogger.ROOT_LOGGER.couldNotLoadClassFromModule(className, moduleID);
} catch (InstantiationException e) {
throw NamingLogger.ROOT_LOGGER.couldNotInstantiateClassInstanceFromModule(className, moduleID);
} catch (IllegalAccessException e) {
throw NamingLogger.ROOT_LOGGER.couldNotInstantiateClassInstanceFromModule(className, moduleID);
} catch (ClassCastException e) {
throw NamingLogger.ROOT_LOGGER.notAnInstanceOfObjectFactory(className, moduleID);
} finally {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(cl);
}
return objectFactoryClassInstance;
}
use of org.jboss.modules.ModuleLoadException in project wildfly by wildfly.
the class JSFDependencyProcessor method addJSFInjection.
private void addJSFInjection(String jsfVersion, ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) throws DeploymentUnitProcessingException {
if (jsfVersion.equals(JsfVersionMarker.WAR_BUNDLES_JSF_IMPL))
return;
ModuleIdentifier jsfInjectionModule = moduleIdFactory.getInjectionModId(jsfVersion);
ModuleDependency jsfInjectionDependency = new ModuleDependency(moduleLoader, jsfInjectionModule, false, true, true, false);
try {
if (isJSF12(jsfInjectionDependency, jsfInjectionModule.toString())) {
JSFLogger.ROOT_LOGGER.loadingJsf12();
jsfInjectionDependency.addImportFilter(PathFilters.is("META-INF/faces-config.xml"), false);
jsfInjectionDependency.addImportFilter(PathFilters.is("META-INF/1.2/faces-config.xml"), true);
} else {
JSFLogger.ROOT_LOGGER.loadingJsf2x();
jsfInjectionDependency.addImportFilter(PathFilters.getMetaInfFilter(), true);
// Exclude Faces 1.2 faces-config.xml to make extra sure it won't interfere with JSF 2.0 deployments
jsfInjectionDependency.addImportFilter(PathFilters.is("META-INF/1.2/faces-config.xml"), false);
}
} catch (ModuleLoadException e) {
throw JSFLogger.ROOT_LOGGER.jsfInjectionFailed(jsfVersion, e);
}
moduleSpecification.addSystemDependency(jsfInjectionDependency);
}
use of org.jboss.modules.ModuleLoadException in project wildfly by wildfly.
the class JSFSharedTldsProcessor method getMap.
private Map<String, List<TldMetaData>> getMap() {
final Map<String, List<TldMetaData>> jsfTldMap = new HashMap<>();
JSFModuleIdFactory moduleFactory = JSFModuleIdFactory.getInstance();
List<String> jsfSlotNames = moduleFactory.getActiveJSFVersions();
for (String slot : jsfSlotNames) {
final List<TldMetaData> jsfTlds = new ArrayList<TldMetaData>();
try {
ModuleClassLoader jsf = Module.getModuleFromCallerModuleLoader(moduleFactory.getImplModId(slot)).getClassLoader();
for (String tld : JSF_TAGLIBS) {
InputStream is = jsf.getResourceAsStream("META-INF/" + tld);
if (is != null) {
TldMetaData tldMetaData = parseTLD(is);
jsfTlds.add(tldMetaData);
}
}
} catch (ModuleLoadException e) {
// Ignore
} catch (Exception e) {
// Ignore
}
jsfTldMap.put(slot, jsfTlds);
}
return jsfTldMap;
}
use of org.jboss.modules.ModuleLoadException in project wildfly by wildfly.
the class JPAExtension method initialize.
@Override
public void initialize(ExtensionContext context) {
SubsystemRegistration registration = context.registerSubsystem(SUBSYSTEM_NAME, CURRENT_MODEL_VERSION);
final ManagementResourceRegistration nodeRegistration = registration.registerSubsystemModel(JPADefinition.INSTANCE);
nodeRegistration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);
registration.registerXMLElementWriter(new JPASubsystemElementParser1_1());
try {
PersistenceProviderLoader.loadDefaultProvider();
} catch (ModuleLoadException e) {
ROOT_LOGGER.errorPreloadingDefaultProvider(e);
}
if (context.isRuntimeOnlyRegistrationValid()) {
registration.registerDeploymentModel(JPADefinition.DEPLOYMENT_INSTANCE);
}
}
use of org.jboss.modules.ModuleLoadException in project wildfly by wildfly.
the class HostExcludesTestCase method retrieveAvailableExtensions.
/**
* Retrieve the list of all modules which export locally a resource that implements a org.jboss.as.controller.Extension.
* This list is considered the list of all available extensions that can be added to a server.
*
* It is assumed that the module which is added as an extension has the org.jboss.as.controller.Extension service as
* a local resource.
*/
private Set<String> retrieveAvailableExtensions() throws IOException {
final Set<String> result = new HashSet<>();
LocalModuleLoader ml = new LocalModuleLoader(getModuleRoots());
Iterator<String> moduleNames = ml.iterateModules((String) null, true);
while (moduleNames.hasNext()) {
String moduleName = moduleNames.next();
Module module;
try {
module = ml.loadModule(moduleName);
List<Resource> resources = module.getClassLoader().loadResourceLocal("META-INF/services/org.jboss.as.controller.Extension");
if (!resources.isEmpty()) {
result.add(moduleName);
}
} catch (ModuleLoadException e) {
Logger.getLogger(HostExcludesTestCase.class).warn("Failed to load module " + moduleName + " to check if it is an extension", e);
}
}
return result;
}
Aggregations