sentry-java
sentry-java copied to clipboard
Investigate ways of supporting javax and jakarta for Spring and Spring Boot
Description
We've decided to duplicate sentry-servlet
(javax) into sentry-servlet-jakarta
(jakarta) to support both as it's only three files that rarely change.
For Spring and Spring Boot we'd like to avoid duplication so we want to find out possible ways of supporting both.
See https://github.com/getsentry/sentry-java/issues/1789
Any news on this? We are currently running Spring Boot v3-M3 and we are unable to use the Sentry SDK at this time.
@rauldeheer we don't have a schedule for this yet, it's very high on the backlog though.
Current state of investigation:
Our current artifacts that depend on javax
can be transformed to Jakarta namespace with Eclipse Transformer.
Manual step by step guide:
-
Download & unzip Eclipse Transformer CLI distribution.
-
Transform JARs:
$ java -jar org.eclipse.transformer.cli-0.5.0.jar ~/.m2/repository/io/sentry/sentry-spring-boot-starter/6.2.1/sentry-spring-boot-starter-6.2.1.jar ~/.m2/repository/io/sentry/sentry-spring-boot-starter/6.2.1/sentry-spring-boot-starter-6.2.1-jakarta.jar
$ java -jar org.eclipse.transformer.cli-0.5.0.jar ~/.m2/repository/io/sentry/sentry-spring/6.2.1/sentry-spring-6.2.1.jar ~/.m2/repository/io/sentry/sentry-spring/6.2.1/sentry-spring-6.2.1-jakarta.jar
- Include transformed files in
pom.xml
usingclassifier
:
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-spring-boot-starter</artifactId>
<version>6.2.1</version>
<classifier>jakarta</classifier>
<exclusions>
<exclusion>
<groupId>io.sentry</groupId>
<artifactId>sentry-spring</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-spring</artifactId>
<version>6.2.1</version>
<classifier>jakarta</classifier>
</dependency>
This proves that Transformer works and can be used to produce Jakarta compatible artifacts, but of course we cannot recommend going through this process to our users. We need one of:
- Produce Jakarta compatible artifacts in our build process - that's possible (Hibernate does it), but there's not straightforward out-of-the-box working solution other than 3rd party https://github.com/sebersole/jakarta-transformer-plugin ~that I haven't tested yet~ Project is unsupported anymore.
Update: project has moved to https://github.com/hibernate/jakarta-transformer-plugin/
- Simplify the guide so that it's a single step process and does not require installing Jakarta artifacts to Maven repository manually (perhaps with
transformer-maven-plugin
).
I played with jakarta-transformer-plugin
and came up with following:
- Create a new module
sentry-spring-jakarta
with followingbuild.gradle
:
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.springframework.boot.gradle.plugin.SpringBootPlugin
plugins {
`java-library`
kotlin("jvm")
id("org.hibernate.jakarta-transformer") version "0.9.6"
id(Config.BuildPlugins.springBoot) version Config.springBootVersion apply false
id(Config.BuildPlugins.springDependencyManagement) version Config.BuildPlugins.springDependencyManagementVersion
}
the<DependencyManagementExtension>().apply {
imports {
mavenBom(SpringBootPlugin.BOM_COORDINATES)
}
}
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString()
kotlinOptions.languageVersion = Config.kotlinCompatibleLanguageVersion
}
dependencies {
// Specifying the transformer's dependencies is optional. 0.2.0 is used by default
jakartaTransformerTool(
"org.eclipse.transformer:org.eclipse.transformer:0.2.0",
)
jakartaTransformerTool("org.eclipse.transformer:org.eclipse.transformer.cli:0.2.0")
}
jakartaTransformation {
shadow(projects.sentrySpring) {
withJavadoc()
withSources()
}
}
Calling from the module directory:
$ ../gradlew clean shadow
results in artifacts:
-rw-r--r-- 1 maciej staff 261 Jul 22 15:52 sentry-spring-jakarta-6.3.0-javadoc.jar
-rw-r--r-- 1 maciej staff 261 Jul 22 15:52 sentry-spring-jakarta-6.3.0-sources.jar
-rw-r--r-- 1 maciej staff 54071 Jul 22 15:52 sentry-spring-jakarta-6.3.0.jar
But running gradlew build
produces:
Execution failed for task ':sentry-spring-jakarta:publishMavenPublicationToMavenLocal'.
> Failed to publish publication 'maven' to repository 'mavenLocal'
> Invalid publication 'maven': multiple artifacts with the identical extension and classifier ('jar', 'sources').
So this part would need to be solved.
Running plugin with the latest version of Eclipse Transformer 0.5.0 results in error (https://github.com/hibernate/jakarta-transformer-plugin/issues/4)
This for now ends my investigation. I think this provides enough research and groundwork to finish the implementation, as it will be mostly playing and configuring Gradle.
New module is committed to branch: https://github.com/getsentry/sentry-java/tree/gh-1984
Any news on this? We've also had to stop using Sentry due to lack of support.
@TomBeckett we're looking to add support in the near future - no detailed timeline yet but we plan to have support for the release at the latest.
@adinauer Thanks for update. Anything the community can do to assist?
@TomBeckett I guess @maciejwalkowiak has already done a lot of the ground work. At this point I assume we can make it work. Maybe we'll need help if we can't figure out a way around issues like the one linked by Maciej above. We'll post here once we know more.
Do you need any help? Please let us know. @adinauer @maciejwalkowiak
Thanks for the offer @rauldeheer . We're planning to take a look at this in the coming weeks. Will let you know as soon as we have specific things we need help with.
Spring Boot 3 RC1 is aiming to be ready around 20th October.
Would it be possible to have Sentry available for testing against that RC? @adinauer
@TomBeckett work on it has begun. Can't state a specific release date yet.
@TomBeckett @rauldeheer we've just released 6.7.0-alpha.1 which has separate modules for supporting Spring 6 (sentry-spring-jakarta
) and Spring Boot 3 (sentry-spring-boot-starter-jakarta
). We also have samples for them available Spring and Spring Boot. If you decide to give it a try, any feedback is very welcome :-)
@adinauer Are these available on maven? Do I need both sentry-servlet-jakarta
and sentry-spring-boot-starter
?
Hey @TomBeckett , I assume it takes a bit until the packages arrive at the different Maven mirrors. I see it here: https://repo1.maven.org/maven2/io/sentry/sentry-spring-boot-starter-jakarta/6.7.0-alpha.1/
Do I need both sentry-servlet-jakarta and sentry-spring-boot-starter ?
Actually none of those. You want sentry-spring-boot-starter-jakarta
for Spring Boot or sentry-spring-jakarta
for Spring. Note the jakarta
in the name.
We've been running this for a few hours in our dev environment - so far so good. I'll open any issues as I see them but early signs are good.
Please pass on my thanks for the team @adinauer (with a big shout out to @lbloder!) for getting it done early before the RC. It really helps us get ready internally 👍
@adinauer Just one last update - No issues encountered using this beta build.
FYI it's been good to get Sentry back - it really is a fantastic product.
Thanks again for releasing an early version for us to use 👍
@TomBeckett that's great to hear. Thanks for the kind words ❤️
Closing this now as version 3.0.0
of Spring Boot has been released and it seems to be working. Version has just been bumped in https://github.com/getsentry/sentry-java/pull/2389