Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate ways of supporting javax and jakarta for Spring and Spring Boot #1984

Closed
adinauer opened this issue Apr 12, 2022 · 20 comments
Closed
Assignees

Comments

@adinauer
Copy link
Member

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 #1789

@rauldeheer
Copy link

Any news on this? We are currently running Spring Boot v3-M3 and we are unable to use the Sentry SDK at this time.

@adinauer
Copy link
Member Author

@rauldeheer we don't have a schedule for this yet, it's very high on the backlog though.

@maciejwalkowiak
Copy link
Contributor

maciejwalkowiak commented Jul 22, 2022

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:

  1. Download & unzip Eclipse Transformer CLI distribution.

  2. 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
  1. Include transformed files in pom.xml using classifier:
<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:

  1. 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/

  1. 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).

@maciejwalkowiak
Copy link
Contributor

maciejwalkowiak commented Jul 22, 2022

I played with jakarta-transformer-plugin and came up with following:

  1. Create a new module sentry-spring-jakarta with following build.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 (hibernate/jakarta-transformer-plugin#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.

@maciejwalkowiak
Copy link
Contributor

New module is committed to branch: https://github.com/getsentry/sentry-java/tree/gh-1984

@TomBeckett
Copy link

Any news on this? We've also had to stop using Sentry due to lack of support.

@adinauer
Copy link
Member Author

@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.

@TomBeckett
Copy link

@adinauer Thanks for update. Anything the community can do to assist?

@adinauer
Copy link
Member Author

adinauer commented Sep 1, 2022

@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.

@rauldeheer
Copy link

Do you need any help? Please let us know. @adinauer @maciejwalkowiak

@adinauer
Copy link
Member Author

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.

@lbloder lbloder self-assigned this Sep 29, 2022
lbloder added a commit that referenced this issue Sep 30, 2022
@TomBeckett
Copy link

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

@adinauer
Copy link
Member Author

adinauer commented Oct 6, 2022

@TomBeckett work on it has begun. Can't state a specific release date yet.

@adinauer
Copy link
Member Author

@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 :-)

@TomBeckett
Copy link

@adinauer Are these available on maven? Do I need both sentry-servlet-jakarta and sentry-spring-boot-starter ?

@adinauer
Copy link
Member Author

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.

@TomBeckett
Copy link

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 👍

@TomBeckett
Copy link

@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 👍

@adinauer
Copy link
Member Author

@TomBeckett that's great to hear. Thanks for the kind words ❤️

@adinauer
Copy link
Member Author

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 #2389

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

5 participants