How to integrate Java Wildfly Swarm applications with Sentry?

We have a Java Wildfly Swarm application and I’m trying to configure it to report Sentry events.

Referenced versions:

  • Wildfly BOM: org.wildfly.bom:wildfly-javaee7:10.1.0.Final
  • Swarm Plugin: org.wildfly.swarm:wildfly-swarm-plugin:2017.12.1

I added the following configurations:

<!-- pom.xml -->
<dependency>
  <groupId>io.sentry</groupId>
   <artifactId>sentry</artifactId>
   <version>1.7.13</version>
</dependency>
# project-defautls.yml
swarm:
  logging:
    pattern-formatters:
      LOG_FORMATTER:
        pattern: "%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p (%t) [%c.%M()] %s%e%n"
    console-handlers:
      CONSOLE:
        named-formatter: LOG_FORMATTER
        level: INFO
    custom-handlers:
      SENTRY:
        module: com.sentry.jul
        attribute-class: io.sentry.jul.SentryHandler
        named-formatter: LOG_FORMATTER
        level: INFO
    root-logger:
      handlers:
      - CONSOLE
      - SENTRY
<!-- module.xml -->
<module xmlns="urn:jboss:module:1.3" name="com.sentry.jul">
    <resources>
        <artifact name="io.sentry:sentry:1.7.13" />
    </resources>
</module>
# Environment variable
SENTRY_DSN=***********

The application starts normally, but the following code snippet is not generating Sentry events:

try {
  throw new Exception("Testing...");
} catch(Exception e) {
  logger.log(Level.SEVERE, "ERROR {0}", e.getMessage());
}

By other hand, it works fine when I configure Sentry by code and generate an event:

Sentry.init(System.getenv("SENTRY_DSN"));
SentryClient sentry = SentryClientFactory.sentryClient();
try {
  throw new Exception("Testing...");
} catch(Exception e) {
  sentry.sendException(e);
}

What is going wrong?

After debugging the code I realized my module definition was incomplete. I had to add other artifacts and dependencies:

<module xmlns="urn:jboss:module:1.3" name="com.sentry.jul">
	<resources>
		<artifact name="io.sentry:sentry:1.7.13" />	
		<artifact name="com.fasterxml.jackson.core:jackson-core:2.8.7" />		
	</resources>
	<dependencies>
		<module name="javax.api" />
		<module name="javax.servlet.api" />
		<module name="org.slf4j"/>
	</dependencies>
</module>

Also I noticed there is no need to keep a project dependency to Sentry.

That’s all!