Skip to content

Make JFR optional to support minimized JREs without jdk.jfr module#5334

Open
nikitanagar08 wants to merge 1 commit intospring-projects:mainfrom
nikitanagar08:fix-5326-jfr-optional
Open

Make JFR optional to support minimized JREs without jdk.jfr module#5334
nikitanagar08 wants to merge 1 commit intospring-projects:mainfrom
nikitanagar08:fix-5326-jfr-optional

Conversation

@nikitanagar08
Copy link

Fixes #5326

Problem:
TaskExecutorJobOperator.start() creates a JobLaunchEvent which extends jdk.jfr.Event. On minimized JREs without the jdk.jfr module, this causes NoClassDefFoundError: jdk/jfr/Event.

Solution:
Wrap the JFR event creation in a try-catch block to handle the case when JFR is not available, allowing Spring Batch to work on minimized JREs without JFR support.

TaskExecutorJobOperator.start() creates a JobLaunchEvent which
extends jdk.jfr.Event. On minimized JREs without the jdk.jfr module,
this causes NoClassDefFoundError: jdk/jfr/Event.

This commit wraps the JFR event creation in a try-catch block to
handle the case when JFR is not available, allowing Spring Batch
to work on minimized JREs without JFR support.

Fixes spring-projects#5326

Signed-off-by: Nikita Nagar <permanayan84@gmail.com>
@nikitanagar08 nikitanagar08 force-pushed the fix-5326-jfr-optional branch from a398a9f to 2b29dcb Compare March 12, 2026 05:00
@nikitanagar08
Copy link
Author

This PR fixes #5326 - ClassNotFoundException when using minimized JREs without the jdk.jfr module. The fix makes JFR optional by wrapping JFR event creation in a try-catch block to handle NoClassDefFoundError, allowing Spring Batch to work on minimized JREs without JFR support.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

java.lang.ClassNotFoundException: jdk.jfr.Event with minimized JRE

1 participant