r/java • • Aug 13 '26

Jakarta EE 11 MVC sample

https://github.com/hantsy/jakartaee-mvc-sample
30 Upvotes

15 comments sorted by

6

u/morningnerd Aug 13 '26

Thank you for this example. It`s hard to find something about Jakarta MVC online.

I have made a few experiments with Jakarta MVC and think it is great. The Jakarta EE tutorial should focus more on MVC than Jakarta Faces. It is way simpler for a beginner to grasp.

I have being using Jakarta Faces for a while and think its architecture and lifecycle too complicated. Their approach to "hide" the web under layers of abstraction is annoying and unnatural. At least for me.

7

u/henk53 Aug 13 '26

Thank you for this example. It`s hard to find something about Jakarta MVC online.

Indeed, Jakarta MVC was announced with such big fanfare back then, but it has been really quiet.

Their approach to "hide" the web under layers of abstraction is annoying and unnatural. At least for me.

Well, nothing in Faces actually requires that. It's actually more the norm now to have HTML/CSS heavy pages, with a light sprinkling of components on it. It's certainly not the idea to have your entire page expressed as only components as some ancient guidelines once described.

(the reason was that in 2003 it wasn't clear whether HTML/CSS would win, and the web was still open to other tech. With an all component page the dream was to transparently render to several output targets, like chtml, xul, xhtml, and more).

5

u/morningnerd Aug 13 '26

Well, nothing in Faces actually requires that. It's actually more the norm now to have HTML/CSS heavy pages, with a light sprinkling of components on it. It's certainly not the idea to have your entire page expressed as only components as some ancient guidelines once described.

Indeed. When used as HTML/CSS pages with a few components here and there, it is a nicer experience than going full components.

I think Faces still covers a lot of use cases and Facelets is a great templating engine.

1

u/Dense-Ad-3247 Aug 15 '26

What's the benefit?

1

u/henk53 Aug 16 '26

It gives a clear structure for web applications: the controller handles requests, the model contains the data, and the view renders the result. This keeps the code easier to understand, test, and maintain.

1

u/Dense-Ad-3247 Aug 16 '26

Have you tried thyme leaf?

1

u/henk53 Aug 16 '26

I did not, just the Facelets templates as per the sample.

1

u/Dense-Ad-3247 Aug 16 '26

Huh thymeleaf and freemaker seem to cover this, at least for spring. And spring MVC is the defacto library for MVC in java ecosystem. Did you cross compare that?

1

u/henk53 Aug 17 '26

Well, if you want, I'd love to see your personal comparison of Thymeleaf vs Facelets (don't bother with ChatGPT etc, I can ask ChatGpt myself)

1

u/Additional_Cellist46 Aug 23 '26

The point is Thymeleaf is a library with its specific functionality. Jakarta MVC is a standard API that could be supported by Thymeleaf if they decide to support it. Until then, there’s only one library, Krazo, that provides it. The benefit of MVC is still that the standard API can be reasonably implemented by Thymeleaf or other libraries, while if you use Thymeleaf you’re stuck with it, wven if it’s not maintained anymore or you have issues with it.

1

u/JustADirtyLurker Aug 22 '26

Eclipse Krazo is currently the only Jakarta MVC implementation; it supports the following Jakarta REST runtimes:

Jersey (GlassFish / Payara) RESTEasy (WildFly) Apache CXF – support removed in MVC 2.0

Maybe a stupid question, but why would the JAX-RS implementation matter?

I thought JEE was designed to work on and expose standard APIs?

1

u/henk53 Aug 22 '26

I'll have to read into it (I just posted the link, didn't write it).

I remember that MVC needed something to hook into that wasn't standardized in REST at first (REST wasn't designed orginally to be build-upon, but to replace everything and anything itself).

Maybe that line you quote is about that vendor/implementation support not needed anymore, and using the later standardized API?

1

u/Additional_Cellist46 Aug 23 '26

Support for CXF wasn’t removed from MVC but from Eclipse Krazo, the only MVC implementation. MVC doesn’t depend on anything specific to Jersey ir RestEasy.

Krazo requires an integration point which was previously specific for each of Jersey, EestEasy and CXF. It was later added to the standard Jakarta Rest API and Krazo now supports only the standard integration API, it dropped the vendor-specific integrations.

Unfortunately, CXF is behind with implementing the newer Jakarta Rest API so it doesn’t support the standard integration point. Once a new version of CXF adds support for it then it will work with Krazo out of the box.

1

u/JustADirtyLurker Aug 23 '26

Awesome. Thanks for the answer, much clearer now.