Search in sources :

Example 11 with ModuleLoadException

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);
    }
}
Also used : ModuleLoadException(org.jboss.modules.ModuleLoadException) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) HashMap(java.util.HashMap) WarMetaData(org.jboss.as.web.common.WarMetaData) ArrayList(java.util.ArrayList) ModuleIdentifier(org.jboss.modules.ModuleIdentifier) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 12 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 13 with ModuleLoadException

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);
    }
}
Also used : TldMetaData(org.jboss.metadata.web.spec.TldMetaData) ModuleLoadException(org.jboss.modules.ModuleLoadException) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) WarMetaData(org.jboss.as.web.common.WarMetaData) Resource(org.jboss.modules.Resource) ArrayList(java.util.ArrayList) ListenerMetaData(org.jboss.metadata.web.spec.ListenerMetaData) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) HashSet(java.util.HashSet)

Example 14 with ModuleLoadException

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);
    }
}
Also used : ModuleLoadException(org.jboss.modules.ModuleLoadException) ModuleLoader(org.jboss.modules.ModuleLoader) PredicatedHandler(io.undertow.server.handlers.builder.PredicatedHandler) Module(org.jboss.modules.Module)

Example 15 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)

Aggregations

ModuleLoadException (org.jboss.modules.ModuleLoadException)18 Module (org.jboss.modules.Module)11 ModuleIdentifier (org.jboss.modules.ModuleIdentifier)6 IOException (java.io.IOException)4 OperationFailedException (org.jboss.as.controller.OperationFailedException)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)3 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)3 WarMetaData (org.jboss.as.web.common.WarMetaData)3 ModuleClassLoader (org.jboss.modules.ModuleClassLoader)3 InputStream (java.io.InputStream)2 URL (java.net.URL)2 Driver (java.sql.Driver)2 HashSet (java.util.HashSet)2 ModuleSpecification (org.jboss.as.server.deployment.module.ModuleSpecification)2 ModelNode (org.jboss.dmr.ModelNode)2 TldMetaData (org.jboss.metadata.web.spec.TldMetaData)2 ServiceTarget (org.jboss.msc.service.ServiceTarget)2 VirtualFile (org.jboss.vfs.VirtualFile)2