Java EE (JBoss) integration (advice)

In near future I’ll be implementing Sentry (on-premise) with Java EE project.

Any instructions, advice in advance?

For setting up self-hosted, you can follow

For Java EE, we have sentry-java but pinging @bruno-garcia in case he has some more information he can share regarding this.

The instructions on how to setup the SDK are part of creating a new project in Sentry.
Let us know if you have any problems or suggestions.

we are already using sentry self-hosted, just not yet for java (EE)

I’m looking at this example in regards to triggering events.

    try {
       int example = 1 / 0;
    } catch (Exception e) {
      logger.error("Caught exception!", e);

I’m sure this is more of a java question rather than a sentry(sdk) version but ; what if an error happens and is not sent to logger.error()?

Is it sent to sentry?

The problem is that all code blocks are not ‘equipped’ with try/catch blocks and subsequently with logger.error()…how do these errors arrive to sentry?

hi @bruno-garcia, can you offer any advice or at least point me to any direction?

Sentry’s Java SDK also capture unhandled exceptions. So if the process is going to crash, Sentry will send an event for that

1 Like

@bruno-garcia, thanks for the reply.

What I did

  • log4j2.xml file
  • and dns=myprojectdsn entry
  • sentry-log4j2 dependency through maven

Shoud, in this case/configuration, uncaught exceptions also be caught? I can verify that, if ‘pushed’ trough logger.error(), the error is shown in Sentry. But uncaught (the same mistake) isn’t.

Should I explicitly install ‘sentry’ through maven?

It’s been a while since I worked with JBoss but as far as I can tell: either you need to catch the exception (in case you use JAX-RS take a look here how this can be done) or you need to configure JBoss to use log4j2 and configure SentryAppender there. You may find this guide useful.

Yes, but this is exactly what is done with sentra-log4j2 package :slight_smile: (?)

Keep in mind that sentry-java master is a base for 3.0 version which is very different from the 1.7.x that you are likely using (?).

In both cases, SDK comes with a Sentry appender that must be configured - either in application or in the application server. Is this unhandled exception logged using log4j2 configured in your application, or is it logged with loggers managed by JBoss?

hi, @maciejwalkowiak

yes, using 1.7


Uncaught exception is logged by (and is not in Sentry) :

‘Caught’ exception (logger.error()) is logged in Sentry :

It seems that, somehow, I need to override default ejb logging?

Some updated info of what I did :

I added an additional exception ( int a = 1 / 0; ) which is not logged in Sentry (in both examples).

What I’m i doing wrong / not understanding?

We need a lot more information to be able to answer this question. Are you using a self-hosted Sentry (I think you do based on your initial message)? Then have you checked its logs to see if the events are actually getting to your Sentry instances? If that’s the case do all workers and services run properly?


I’m using self-hosted sentry, yes, latest version (20+).

For the errors that do come to Sentry, I see information in logs. For the uncaught errors, there is nothing - nothing in logs, no tcpdump traffic.

Sounds like a an SDK related thing then. Pinging @bruno-garcia

We’ve release Java 3.0 this week, could you please try it out?

Docs for log4j2 are here:

1 Like

Good information thanks for sharing

@bruno-garcia ; just replacing 1.7.30 with 3.0.0 in pom.xml causes this :

package org.apache.logging.log4j does not exist

Output of mvn dependency:tree

[INFO] — maven-dependency-plugin:2.8:tree (default-cli) @ sentry-java-log4j2-example —
[INFO] io.sentry:sentry-java-log4j2-example:jar:1.0-SNAPSHOT
[INFO] ± io.sentry:sentry-log4j2:jar:3.0.0:compile
[INFO] | ± io.sentry:sentry:jar:3.0.0:compile
[INFO] | | -
[INFO] | ± org.apache.logging.log4j:log4j-api:jar:2.13.3:runtime
[INFO] | - org.apache.logging.log4j:log4j-core:jar:2.13.3:runtime
[INFO] - org.slf4j:slf4j-simple:jar:1.7.22:compile
[INFO] - org.slf4j:slf4j-api:jar:1.7.22:compile

org.apache.logging.log4j:log4j-api:jar is set as a runtime dependency - meaning we don’t bring this dependency and you need to include it yourself.

Please just add the dependency to log4j2 in your Maven or Gradle configuration file and this issue will be resolved.

Thanks for the info.

Created a simple .war (for our JBOSS EAP 7.2) - no luck

Error is sent to Sentry :

private static final Logger logger = LogManager.getLogger(TestProjectRest.class.getName());
try {
int example = 1/0;
} catch (Exception e) {
logger.error(“Uncaught exception in TestProjectRest!”, e);
return Response.serverError().entity("{“Error”:"" + “”}").build();

First line of server.log (JBOSS):


Error is not sent to Sentry :

private static final Logger logger = LogManager.getLogger(TestProjectRest.class.getName());
int example = 1/0;

First line of server.log (JBOSS):