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;
}
}
Aggregations