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 https://develop.sentry.dev/self-hosted/

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
  • sentry.properties 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

<dependency>
   <groupId>io.sentry</groupId>
   <artifactId>sentry-log4j2</artifactId>
   <version>1.7.30</version>

Uncaught exception is logged by (and is not in Sentry) :
“loggerClassName”:“org.jboss.as.ejb3.logging.EjbLogger_$logger”

‘Caught’ exception (logger.error()) is logged in Sentry :
“loggerClassName”:“org.jboss.logmanager.Logger”

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?