Search in sources :

Example 31 with ModuleLoadException

use of org.jboss.modules.ModuleLoadException in project wildfly by wildfly.

the class ModuleClassLoaderProvider method getServerIntegrationClassLoader.

@Override
public ClassLoader getServerIntegrationClassLoader() {
    if (integrationClassLoader == null || integrationClassLoader.get() == null) {
        try {
            Module module = Module.getBootModuleLoader().loadModule(ASIL);
            integrationClassLoader = new WeakReference<ClassLoader>(module.getClassLoader());
        } catch (ModuleLoadException e) {
            throw new RuntimeException(e);
        }
    }
    return integrationClassLoader.get();
}
Also used : ModuleLoadException(org.jboss.modules.ModuleLoadException) Module(org.jboss.modules.Module)

Example 32 with ModuleLoadException

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
    }
}
Also used : TldMetaData(org.jboss.metadata.web.spec.TldMetaData) ModuleLoadException(org.jboss.modules.ModuleLoadException) ModuleClassLoader(org.jboss.modules.ModuleClassLoader) InputStream(java.io.InputStream) IOException(java.io.IOException) ModuleLoadException(org.jboss.modules.ModuleLoadException)

Example 33 with ModuleLoadException

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);
    }
}
Also used : ModuleLoadException(org.jboss.modules.ModuleLoadException) MalformedURLException(java.net.MalformedURLException) JarURLConnection(java.net.JarURLConnection) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) IOException(java.io.IOException) Module(org.jboss.modules.Module) JarFile(java.util.jar.JarFile) URL(java.net.URL) URLConnection(java.net.URLConnection) JarURLConnection(java.net.JarURLConnection)

Example 34 with ModuleLoadException

use of org.jboss.modules.ModuleLoadException in project teiid by teiid.

the class TranslatorDependencyDeployer method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    try {
        final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
        // $NON-NLS-1$
        final ModuleLoader moduleLoader = Module.getCallerModule().getModule(ModuleIdentifier.create("org.jboss.teiid")).getModuleLoader();
        // $NON-NLS-1$
        moduleSpecification.addLocalDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.create("org.jboss.teiid.api"), false, false, false, false));
        // $NON-NLS-1$
        moduleSpecification.addLocalDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.create("org.jboss.teiid.common-core"), false, false, false, false));
        // $NON-NLS-1$
        moduleSpecification.addLocalDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.create("javax.api"), false, false, false, false));
        // $NON-NLS-1$
        moduleSpecification.addLocalDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.create("javax.resource.api"), false, false, false, false));
    } catch (ModuleLoadException e) {
        throw new DeploymentUnitProcessingException(e);
    }
}
Also used : ModuleLoadException(org.jboss.modules.ModuleLoadException) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ModuleLoader(org.jboss.modules.ModuleLoader) ModuleDependency(org.jboss.as.server.deployment.module.ModuleDependency) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 35 with ModuleLoadException

use of org.jboss.modules.ModuleLoadException in project wildfly by wildfly.

the class SharedTldsMetaDataBuilder method getSharedTlds.

public List<TldMetaData> getSharedTlds(DeploymentUnit deploymentUnit) {
    final List<TldMetaData> metadata = new ArrayList<TldMetaData>();
    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(is);
                metadata.add(tldMetaData);
            }
        }
    } catch (ModuleLoadException e) {
    // Ignore
    } catch (Exception e) {
    // Ignore
    }
    List<TldMetaData> additionalSharedTlds = deploymentUnit.getAttachment(ATTACHMENT_KEY);
    if (additionalSharedTlds != null) {
        metadata.addAll(additionalSharedTlds);
    }
    return metadata;
}
Also used : TldMetaData(org.jboss.metadata.web.spec.TldMetaData) ModuleLoadException(org.jboss.modules.ModuleLoadException) ModuleClassLoader(org.jboss.modules.ModuleClassLoader) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ModuleLoadException(org.jboss.modules.ModuleLoadException)

Aggregations

ModuleLoadException (org.jboss.modules.ModuleLoadException)62 Module (org.jboss.modules.Module)30 IOException (java.io.IOException)17 ModuleIdentifier (org.jboss.modules.ModuleIdentifier)13 ModuleSpec (org.jboss.modules.ModuleSpec)12 ModuleLoader (org.jboss.modules.ModuleLoader)10 Test (org.junit.Test)9 URL (java.net.URL)8 File (java.io.File)7 InputStream (java.io.InputStream)7 ArrayList (java.util.ArrayList)7 ModuleClassLoader (org.jboss.modules.ModuleClassLoader)7 HashSet (java.util.HashSet)6 OperationFailedException (org.jboss.as.controller.OperationFailedException)6 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)6 ModelNode (org.jboss.dmr.ModelNode)6 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)5 TldMetaData (org.jboss.metadata.web.spec.TldMetaData)5 ModuleNotFoundException (org.jboss.modules.ModuleNotFoundException)5 HashMap (java.util.HashMap)4