Running AsciidoctorJ on WildFly

If you want to use AsciidoctorJ in an application deployed on WildFly, you have to follow the instruction below:

  1. Create an Asciidoctor module for WildFly.

  2. Create the following folder tree: $JBOSS_HOME/modules/org/asciidoctor/main.

  3. Create the module descriptor file module.xml.

    Asciidoctor module descriptor for WildFly
    <?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.0" name="org.asciidoctor">
        <resources>
            <resource-root path="asciidoctorj-api-2.5.13.jar"/>
            <resource-root path="asciidoctorj-2.5.13.jar"/>
            <resource-root path="jcommander-1.72.jar"/>
            <resource-root path="jruby-complete-9.4.7.0.jar"/>
        </resources>
        <dependencies>
            <module name="sun.jdk" export="true">
                <imports>
                    <include path="sun/misc/Unsafe" />
                </imports>
            </module>
            <module name="javax.management.j2ee.api"/>
            <module name="javax.api"/>
            <module name="org.slf4j"/>
        </dependencies>
    </module>
  4. Copy the jar files into the same folder as the module.xml file.

  5. Make sure the version numbers of the jar files agree with what’s in the current set. Restart WildFly for the new module to take effect.

  6. Add a dependency on your Java archive to this WildFly module using one of the following options:

    1. Add the dependency just into the MANIFEST.MF file.

      MANIFEST.MF file example with dependency to Asciidoctor module
      Manifest-Version: 1.0
      Dependencies: org.asciidoctor
      ...
    2. Or, configure the dependency into the pom.xml with the Maven JAR/WAR plugin.

      pom.xml file example with Maven WAR plugin configuration to add a dependency
      ...
      <dependencies>
        <dependency>
          <groupId>org.asciidoctor</groupId>
          <artifactId>asciidoctorj</artifactId>
          <version>2.5.13</version>
          <scope>provided</scope> (1)
          ...
        </dependency>
      </dependencies>
      ...
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-war-plugin</artifactId>
          <version>2.4</version>
          <configuration>
            <archive>
              <manifestEntries>
                <Dependencies>org.asciidoctor</Dependencies> (2)
              </manifestEntries>
            </archive>
          </configuration>
      </plugin>
      ...
      1 The AsciidoctorJ dependency and the transitives dependencies don’t need to be added to the final WAR since all JARs are available through the module.
      2 The module dependency will be added to the MANIFEST.MF file.