r/java • u/NHarmonia18 • Dec 18 '25
Jakarta REST 3.1 SeBootstrap API: A Lightweight, Standard Way to Bootstrap JAX-RS + Servlet + CDI Apps Without Framework Magic (Virtual Threads Included)
TL;DR:
The new Jakarta REST SeBootstrap API (since 3.1/2022) lets you programmatically start a fully portable JAX-RS server with Servlet and CDI support using a simple main() method – no annotations, no framework-specific auto-configuration. With one dependency (RESTEasy + Undertow + Weld), you get a lean uber-jar (~10 MB), virtual threads per request, and transparent configuration. Why aren't more Java devs using this standard approach for lightweight REST APIs instead of Spring Boot / Quarkus / Micronaut?
As a C# developer who also works with Java, I really appreciate how ASP.NET Core treats the web stack as first-class. You can FrameworkReference ASP.NET Core libraries in a regular console app and bootstrap everything imperatively:
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
var app = builder.Build();
app.MapControllers();
app.Run();
}
}
Self-hosted on Kestrel Web-Server (equivalent of a Servlet Web-Container/Web-Server), no separate web project, no magic annotations – just clean, imperative code.
Now compare that to common Java web frameworks:
Spring Boot
Heavy reliance on magical annotations and auto-configuration.
Quarkus
Once again, we can see heavy reliance on magical annotations and auto-configuration.
Micronaut
Better, but still framework-specific entry points with auto-magic.
Helidon (closer, but no Servlet support)
Even modern Jakarta EE servers like OpenLiberty/WildFly(with Galleon/Glow) that allow decomposition of the server features and can produce runnable JARs, don’t give you a real main() method during development that you can actually run/debug directly from an IDE, thus forcing you to use server-specific Maven/Gradle plugins.
My question:
- Why do most Java web frameworks add framework-specific overhead to startup?
- Why isn’t there a single standard way to bootstrap a Java web application?
While searching, I discovered the Jakarta RESTful Web Services SeBootstrap API (introduced in 3.1):
https://jakarta.ee/specifications/restful-ws/3.1/jakarta-restful-ws-spec-3.1#se-bootstrap
It allows you to programmatically bootstrap a JAX-RS server without knowing the underlying implementation – truly portable, while also allowing optional implementation-specific properties, giving you full control over the startup of an application in a standard and uniform manner.
I tried it using the RESTEasy example repo: https://github.com/resteasy/resteasy-examples/tree/main/bootstrap-cdi
Here’s a slightly enhanced version that adds virtual threads per request and access logging:
RestActivator is just a standard jakarta.ws.rs.core.Application subclass.
Only one dependency needed:
org.jboss.resteasy
resteasy-undertow-cdi
7.0.1.Final
For an uber-jar, use the Shade plugin with ServicesResourceTransformer.
What you get:
- Fully portable Jakarta EE container with Servlet + CDI + JAX-RS
- Standard, implementation-neutral bootstrap API
- Easy virtual thread support (no reactive code needed)
- Imperative configuration – no
beans.xml, noserver.xml - Small uber-jars (~10 MB) – much leaner than framework-specific builds
This feels like a regular console app: easy to run/debug from IDE, minimal dependencies, no magic.
So why isn’t this more popular for lightweight / personal projects?
- Is the API too new (2022)?
- Lingering perception that Jakarta EE is heavyweight (despite specs working fine in Java SE)?
- Lack of marketing / advertising for Jakarta EE features?
It’s ironic that Red Hat pushes Quarkus as “lightweight and portable” while requiring annotations like @RunOnVirtualThread + @Blocking everywhere just to be able to use Virtual Threads. With Undertow + SeBootstrap, you configure virtual threads once at the web-container / servlet level – and Undertow added this capability largely because Spring (which supports Undertow as an embedded server option) enabled virtual thread support a few years ago.
If you just need JAX-RS + Servlet + CDI for a simple REST API, SeBootstrap might be all you need. No full framework overhead, stays lightweight like ASP.NET Core, Flask/FastAPI, or Express.
Java devs seem to love declarative magic – but sometimes a bit of imperative “glue code” is worth the transparency and control.
Thoughts? Anyone else using SeBootstrap in production or side projects?
View all comments
7
u/TheKingOfSentries Dec 18 '25
My dude if you think 20MB is lean have I got a bridge to sell you.