Remote ActiveMQ from a JBoss Module

Latest response

I am trying to update a custom module that implements a custom log handler that pushes information from one EAP 7.2 server to the queue on another for remote logging. Unfortunately, I am having difficulty establishing the InitialContext from the our jar file in the module, because I am getting a ClassNotFoundException on org.wildfly.naming.client.WildFlyInitialContextFactory:

Caused by: java.lang.ClassNotFoundException: org.wildfly.naming.client.WildFlyInitialContextFactory from [Module "org.jboss.as.standalone" from local module loader @6d78f7d2 (finder: local module finder @44d1ed88 (roots: C:\Source\world\eship\eship_ear\target\eship_jboss_7.2-1.2\modules,C:\Source\world\eship\eship_ear\target\eship_jboss_7.2-1.2\modules\system\layers\base))]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:255)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)

I have tried adding the wildfly naming client as a module dependence, but it doesn't seem to solve this issue. Any help resolving this would be greatly appreciated. Here is the client code in the module jar file (I have attached the module.xml file):

        final Properties env = new Properties();
        env.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
        env.put(Context.PROVIDER_URL, "remote+http://" + host + ":" + port);
        env.put(Context.SECURITY_PRINCIPAL, loggingUser);
        env.put(Context.SECURITY_CREDENTIALS, loggingPwd);

        Context namingContext = null;
        try {
            namingContext = new InitialContext(env);

            connectionFactory = (ConnectionFactory) namingContext.lookup("jms/RemoteConnectionFactory");
            destination = (Destination) namingContext.lookup(queue);
            context = connectionFactory.createContext(loggingUser, loggingPwd);
            producer = context.createProducer();

            if (serverName == null) {
                serverName = System.getProperty("jboss.node.name");
            }
            if (serverIP == null) {
                serverIP = System.getProperty("jboss.bind.address");
            }
        } catch (Exception errOpen) {
            errOpen.printStackTrace();
            try {
                if (context != null) {
                    context.close();
                }
            } catch (Exception errClose) {
                // Don't care about these.
            }
            throw errOpen;
        } finally {
            if (namingContext != null) {
                namingContext.close();
            }
        }
  • Module.xml
<module name="org.wildfly.naming-client" xmlns="urn:jboss:module:1.3"

    <resources>
        <resource-root path="wildfly-naming-client-1.0.9.Final-redhat-1.jar"/>
    </resources>

    <dependencies>
        <module name="javax.api"/>
        <module name="org.jboss.logging"/>
        <module name="org.jboss.remoting"/>
        <module name="org.wildfly.common"/>
        <module name="org.wildfly.security.elytron-private"/>
        <module name="org.jboss.ejb-client" services="import" optional="true"/>
        <module name="org.wildfly.transaction.client" services="import" optional="true"/>
    </dependencies>
</module>

Attachments

Responses