Search in sources :

Example 6 with ModuleNotFoundException

use of org.jboss.modules.ModuleNotFoundException in project ceylon by eclipse.

the class AbstractJBossRuntime method createClassLoader.

public ClassLoaderHolder createClassLoader(String name, String version, Configuration conf) throws Exception {
    if (RepositoryManager.DEFAULT_MODULE.equals(name)) {
        if (version != null) {
            throw new CeylonRuntimeException("Invalid module identifier: default module should not have any version");
        }
    } else {
        if (version == null) {
            StringBuilder sb = new StringBuilder("Invalid module identifier: missing required version");
            sb.append(" (should be of the form ");
            sb.append(name);
            sb.append("/version)");
            throw new CeylonRuntimeException(sb.toString());
        }
    }
    ModuleIdentifier moduleIdentifier;
    try {
        moduleIdentifier = ModuleIdentifier.fromString(name + ":" + version);
    } catch (IllegalArgumentException x) {
        CeylonRuntimeException cre = new CeylonRuntimeException("Invalid module name or version: contains invalid characters");
        cre.initCause(x);
        throw cre;
    }
    try {
        ModuleLoader moduleLoader = createModuleLoader(conf);
        Module module = moduleLoader.loadModule(moduleIdentifier);
        return new ClassLoaderHolderImpl(module);
    } catch (ModuleNotFoundException e) {
        String spec = e.getMessage();
        int p = spec.lastIndexOf(':');
        if (p >= 0) {
            spec = spec.substring(0, p) + "/" + spec.substring(p + 1);
        }
        // ModuleIdentifier escapes :
        spec = spec.replace("\\:", ":");
        String msg = "Could not find module: " + spec + " (invalid version?";
        if (name.equals("ceylon.language")) {
            msg += " try running with '--link-with-current-distribution'";
        }
        msg += ")";
        final CeylonRuntimeException cre = new CeylonRuntimeException(msg);
        cre.initCause(e);
        // e.printStackTrace();
        throw cre;
    }
}
Also used : CeylonRuntimeException(ceylon.modules.CeylonRuntimeException) ModuleLoader(org.jboss.modules.ModuleLoader) ModuleNotFoundException(org.jboss.modules.ModuleNotFoundException) ModuleIdentifier(org.jboss.modules.ModuleIdentifier) Module(org.jboss.modules.Module)

Aggregations

Module (org.jboss.modules.Module)6 ModuleNotFoundException (org.jboss.modules.ModuleNotFoundException)6 ModuleIdentifier (org.jboss.modules.ModuleIdentifier)5 ModuleLoadException (org.jboss.modules.ModuleLoadException)5 OperationFailedException (org.jboss.as.controller.OperationFailedException)3 ServiceTarget (org.jboss.msc.service.ServiceTarget)3 Driver (java.sql.Driver)2 CeylonRuntimeException (ceylon.modules.CeylonRuntimeException)1 Closeable (java.io.Closeable)1 File (java.io.File)1 IOException (java.io.IOException)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 ObjectFactory (javax.naming.spi.ObjectFactory)1 DataSource (javax.sql.DataSource)1 XADataSource (javax.sql.XADataSource)1 ConnectionFactoryFactory (org.apache.activemq.artemis.jms.bridge.ConnectionFactoryFactory)1 DestinationFactory (org.apache.activemq.artemis.jms.bridge.DestinationFactory)1 QualityOfServiceMode (org.apache.activemq.artemis.jms.bridge.QualityOfServiceMode)1