Skip to content

Commit

Permalink
Merge pull request #212 from dmlloyd/jbmod
Browse files Browse the repository at this point in the history
Do not fail catastrophically if JBoss Modules is missing
  • Loading branch information
dmlloyd authored Feb 16, 2017
2 parents d90003b + 64d6930 commit 1bfd75f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/main/java/org/jboss/ejb/_private/Logs.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@
import org.jboss.logging.annotations.Message;
import org.jboss.logging.annotations.MessageLogger;
import org.jboss.logging.annotations.Once;
import org.jboss.logging.annotations.Param;
import org.jboss.logging.annotations.Property;
import org.jboss.remoting3.Channel;
import org.wildfly.client.config.ConfigXMLParseException;
import org.wildfly.client.config.ConfigurationXMLStreamReader;

import javax.ejb.EJBException;
import javax.naming.CommunicationException;
Expand Down Expand Up @@ -318,6 +321,11 @@ public interface Logs extends BasicLogger {
@Message(id = 102, value = "No asynchronous operation in progress")
IllegalStateException noAsyncInProgress();

// Configuration problems

@Message(id = 200, value = "Cannot load from a module when jboss-modules is not available")
ConfigXMLParseException noJBossModules(@Param ConfigurationXMLStreamReader streamReader);

// Invocation result exceptions

@Message(id = 400, value = "Remote invocation failed due to an exception")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ private static void parseInterceptorType(final ConfigurationXMLStreamReader stre
ClassLoader cl;
if (moduleName != null) {
try {
cl = Module.getModuleFromCallerModuleLoader(ModuleIdentifier.fromString(moduleName)).getClassLoader();
} catch (ModuleLoadException e) {
throw new ConfigXMLParseException(e);
cl = ModuleLoadDelegate.loadModule(moduleName);
} catch (LinkageError e) {
throw Logs.MAIN.noJBossModules(streamReader);
}
} else {
cl = ConfigurationBasedEJBClientContextSelector.class.getClassLoader();
Expand All @@ -180,6 +180,16 @@ private static void parseInterceptorType(final ConfigurationXMLStreamReader stre
throw streamReader.unexpectedElement();
}

static final class ModuleLoadDelegate {
static ClassLoader loadModule(String moduleName) throws ConfigXMLParseException {
try {
return Module.getModuleFromCallerModuleLoader(ModuleIdentifier.fromString(moduleName)).getClassLoader();
} catch (ModuleLoadException e) {
throw new ConfigXMLParseException(e);
}
}
}

private static void parseConnectionsType(final ConfigurationXMLStreamReader streamReader, final EJBClientContext.Builder builder) throws ConfigXMLParseException {
if (streamReader.getAttributeCount() > 0) {
throw streamReader.unexpectedAttribute(0);
Expand Down

0 comments on commit 1bfd75f

Please sign in to comment.