Skip to content

Commit 39034b5

Browse files
committedNov 27, 2013
Back porting to 1.9.x: MDS doesn't start and shows unfriendly error
message after installing - TRUNK-4019
1 parent d26efb8 commit 39034b5

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed
 

‎api/src/main/java/org/openmrs/module/Module.java

-8
Original file line numberDiff line numberDiff line change
@@ -713,14 +713,6 @@ public void setStartupErrorMessage(String exceptionMessage, Throwable t) {
713713
sb.append(t.getMessage());
714714
sb.append("\n");
715715

716-
// loop over and append all stacktrace elements marking the "openmrs" ones
717-
for (StackTraceElement traceElement : t.getStackTrace()) {
718-
if (traceElement.getClassName().contains("openmrs"))
719-
sb.append(" ** ");
720-
sb.append(traceElement);
721-
sb.append("\n");
722-
}
723-
724716
this.startupErrorMessage = sb.toString();
725717
}
726718

‎api/src/main/java/org/openmrs/module/ModuleFactory.java

+13-5
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,7 @@ public static void startModules() {
284284
// if we failed to start all the modules, error out
285285
if (leftoverModules.size() > 0)
286286
for (Module leftoverModule : leftoverModules) {
287-
String message = "Unable to start module '" + leftoverModule.getName()
288-
+ "'. All required modules are not available: "
289-
+ OpenmrsUtil.join(getMissingRequiredModules(leftoverModule), ", ");
287+
String message = getFailedToStartModuleMessage(leftoverModule);
290288
log.error(message);
291289
leftoverModule.setStartupErrorMessage(message);
292290
notifySuperUsersAboutModuleFailure(leftoverModule);
@@ -522,8 +520,7 @@ public static Module startModuleInternal(Module module) throws ModuleException {
522520

523521
// check for required modules
524522
if (!requiredModulesStarted(module)) {
525-
throw new ModuleException("Not all required modules are started: "
526-
+ OpenmrsUtil.join(getMissingRequiredModules(module), ", ") + ". ", module.getName());
523+
throw new ModuleException(getFailedToStartModuleMessage(module));
527524
}
528525

529526
// fire up the classloader for this module
@@ -661,6 +658,17 @@ public static Module startModuleInternal(Module module) throws ModuleException {
661658
return module;
662659
}
663660

661+
/**
662+
* Gets the error message of a module which fails to start.
663+
*
664+
* @param module the module that has failed to start.
665+
* @return the message text.
666+
*/
667+
private static String getFailedToStartModuleMessage(Module module) {
668+
String[] params = {module.getName(), OpenmrsUtil.join(getMissingRequiredModules(module), ", ")};
669+
return Context.getMessageSourceService().getMessage("Module.error.moduleCannotBeStarted", params, Context.getLocale());
670+
}
671+
664672
/**
665673
* Loop over the given module's advice objects and load them into the Context This needs to be
666674
* called for all started modules after every restart of the Spring Application Context

‎webapp/src/main/webapp/WEB-INF/messages.properties

+1
Original file line numberDiff line numberDiff line change
@@ -1898,6 +1898,7 @@ Module.stopped=Module {0} has been stopped
18981898
Module.error=Error processing Module
18991899
Module.errorStarting=Error starting Module - {0}
19001900
Module.errorClickForDetails=Error starting! Click for details
1901+
Module.error.moduleCannotBeStarted=Module {0} cannot be started because it requires the following module(s): {1} Please install and start these modules first.
19011902
Module.invalid=Invalid module specified {0}
19021903
Module.notStarted=Not Started
19031904
Module.loadedAndStarted=Module loaded and started successfully

0 commit comments

Comments
 (0)
Please sign in to comment.