3

I have a custom Wildfly module for logging in Json format, which my Swarm application references in standalone.xml:

<subsystem xmlns="urn:jboss:domain:logging:3.0">

    <console-handler name="CONSOLE">
        <level name="INFO" />
        <formatter>
            <named-formatter name="json-formatter" />
        </formatter>
    </console-handler>
    ...
    <formatter name="json-formatter">
        <custom-formatter module="my.package.jsonLogFormatter" class="my.package.jsonLogFormatter.JsonFormatter"/>
    </formatter>

</subsystem>

The module is saved in a Maven repository, from which it is copied during the Maven build to the target/classes folder.

The Maven wildfly-swarm-plugin then adds the module to the uberjar:

<plugin>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>wildfly-swarm-plugin</artifactId>
    <version>2017.7.0</version>
    <executions>
        <execution>
            <goals>
                <goal>package</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <additionalModules>
            <additionalModule>jsonLogFormatter-1.2</additionalModule>
        </additionalModules>
    </configuration>
</plugin>

This works as expected when executing from the uberjar.

However, when running a custom main() class directly from the IDE, there seems to be no way to tell Swarm to use this module:

public static void main(String... args) throws Exception {

    new org.wildfly.swarm.Swarm()
         //.customModule("path/to/module") // <- doesn't exist
         .start()
         .deploy();
}

Swarm shows this error during startup:

Failed to load module "my.package.jsonLogFormatter" for formatter "json-formatter"
alin
  • 29
  • 2
  • I don't think that's something we support, and not sure we would as we're trying to move away from main() usage. When it works with the uberjar are you using that main() class in that situation? Whether you are or not, I would try just using the default Swarm main() unless there's something you need that can't be done any other way – Ken Sep 05 '17 at 18:48
  • Thanks! I'm not using a custom main() actually, I was just showing where I expected a custom method for adding a module to be. – alin Sep 06 '17 at 08:19

0 Answers0