diff --git a/controller/src/main/java/org/jboss/as/controller/ControllerMessages.java b/controller/src/main/java/org/jboss/as/controller/ControllerMessages.java index 620205801308..af04199435d9 100644 --- a/controller/src/main/java/org/jboss/as/controller/ControllerMessages.java +++ b/controller/src/main/java/org/jboss/as/controller/ControllerMessages.java @@ -49,6 +49,8 @@ import org.jboss.logging.annotations.MessageBundle; import org.jboss.logging.annotations.Param; import org.jboss.modules.ModuleIdentifier; +import org.jboss.modules.ModuleLoadException; +import org.jboss.modules.ModuleNotFoundException; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.StartException; @@ -2648,4 +2650,10 @@ public interface ControllerMessages { @Message(id = 13452, value = "Legacy extension '%s' is not supported on servers running this version. The extension " + "is only supported for use by hosts running a previous release in a mixed-version managed domain") String unsupportedLegacyExtension(String extensionName); + + @Message(id = 13453, value = "Extension module %s not found") + OperationFailedException extensionModuleNotFound(@Cause ModuleNotFoundException cause, String module); + + @Message(id = 13454, value = "Failed to load Extension module %s") + RuntimeException extensionModuleLoadingFailure(@Cause ModuleLoadException cause, String module); } diff --git a/controller/src/main/java/org/jboss/as/controller/extension/ExtensionAddHandler.java b/controller/src/main/java/org/jboss/as/controller/extension/ExtensionAddHandler.java index 11ac8fa610af..e6a5eabd98b1 100644 --- a/controller/src/main/java/org/jboss/as/controller/extension/ExtensionAddHandler.java +++ b/controller/src/main/java/org/jboss/as/controller/extension/ExtensionAddHandler.java @@ -21,6 +21,7 @@ import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; +import org.jboss.as.controller.ControllerMessages; import org.jboss.as.controller.Extension; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; @@ -30,6 +31,7 @@ import org.jboss.modules.Module; import org.jboss.modules.ModuleIdentifier; import org.jboss.modules.ModuleLoadException; +import org.jboss.modules.ModuleNotFoundException; /** * Base handler for the extension resource add operation. @@ -49,7 +51,7 @@ public class ExtensionAddHandler implements OperationStepHandler { * Create the AbstractAddExtensionHandler * @param extensionRegistry registry for extensions * @param parallelBoot {@code true} is parallel initialization of extensions is in progress; {@code false} if not - * @param slaveHC + * @param slaveHC {@code true} if this handler will execute in a slave HostController */ public ExtensionAddHandler(final ExtensionRegistry extensionRegistry, final boolean parallelBoot, boolean standalone, boolean slaveHC) { assert extensionRegistry != null : "extensionRegistry is null"; @@ -97,8 +99,14 @@ void initializeExtension(String module) throws OperationFailedException { SecurityActions.setThreadContextClassLoader(oldTccl); } } + } catch (ModuleNotFoundException e) { + // Treat this as a user mistake, e.g. incorrect module name. + // Throw OFE so post-boot it only gets logged at DEBUG. + throw ControllerMessages.MESSAGES.extensionModuleNotFound(e, module); } catch (ModuleLoadException e) { - throw new OperationFailedException(new ModelNode().set(e.toString())); + // The module is there but can't be loaded. Treat this as an internal problem. + // Throw a runtime exception so it always gets logged at ERROR in the server log with stack trace details. + throw ControllerMessages.MESSAGES.extensionModuleLoadingFailure(e, module); } }