23

Java EE was donated to the Eclipse Foundation which had to rename it to Jakarta EE.

In the process, they had to change the dependency coordinates of the specifications and change the root package name.

It is not possible to mix Java EE and Jakarta EE (though there are tools for converting between them).

Now, if an application uses old Java EE dependencies on a Jakarta EE application server (or vice-versa), there will be compatibility issues as the server expects the application to use jakarta.* types while the application references javax.* types.

There are multiple questions (like this) where the OP is confused about problems arising from it.

I propose to add a canonical explaining the following:

  • What is the difference between Java EE and Jakarta EE?
    • explain that Java EE has been changed to Jakarta EE which includes renaming the javax package and changing the artifact coordinates
  • What does one need to take care about in order to avoid compatibility issues?
    • You should either only have Java EE dependencies or Jakarta EE dependencies
      • include a link or list of changed dependencies
    • Other (non-Java/Jakarta EE) dependencies need to be compatible with what is used, e.g. Hibernate 5 is for Java EE while Hibernate 6 is for Jakarta EE, similar for Spring Boot 2 vs Spring Boot 3
    • The version of the application server/servlet container must support what you are using (e.g. Tomcat <=9 uses Java EE while Tomcat >=10 uses Jakarta EE).
      • the root package name for Java EE imports needs to be javax and the root package name for Jakarta EE imports needs to be jakarta. This cannot be mixed.

Any comments, agreements or disagreements?

8
  • I... guess? In my opinion if you are doing JEE dev and you run into this issue, you're doing it wrong. The dependencies should be managed for you by coming in transitively through some other uber-dependency. So I wouldn't approach a canonical from a low level dependency management perspective, but more from a high level dependency management perspective. What do you need to do to correctly manage dependencies for a JEE project so you don't run into this issue to begin with?
    – Gimby
    Nov 16 at 8:34
  • 1
    This happened back in 2018 and no proper canonical is available? Well, I guess better late than never, assuming you've done a good check.
    – Erik A
    Nov 16 at 8:54
  • I agree with a canonical, but I would focus on the second question (the compatibility issues) since that sounds more practical and it's what most people get stuck with from my experience. Including the first and second question in a single canonical would also make it too broad I think.
    – g00glen00b
    Nov 16 at 13:14
  • 1
    Yeah I would just add the first question to either the question or the answer to explain why that is a problem
    – dan1st
    Nov 16 at 13:57
  • I use this as a canonical answer in the Tomcat context. Can you come up with a more generic question/answer that makes sense when asked from any underlying problem? E.g. in the Tomcat context it's easy to point at the Version 9 -> 10 bump. I'm not sure how many contexts it needs for a truly generic canonical that still makes sense to the askers (who all come from a specific context) -
    – Olaf Kock
    Nov 16 at 16:29
  • There can be people that have both Java EE and Jakarta EE dependencies (sometimes transitively) in their projects or people use a dependency (like Hibernate) that does not match the Java/Jakarta EE version. I mainly want to have a canonical since there are quite a few issues arising from it.
    – dan1st
    Nov 16 at 16:56
  • 1
    Related (2018): Rename [java-ee] to [jakarta-ee] Nov 16 at 23:44
  • 3
    Once upon a time Java was "Write once, run everywhere". Now it is "Here be dragons". Nov 17 at 21:12

2 Answers 2

13

I don't know if I agree.

Dealing with jakarta vs javax depends on your implementation/use case. Having completed a full migration of applications from Java 8 to Java 17 and Spring Boot 3, I feel like our difficulty in getting this to work was between "oh, update this dependency and swap your packages and you're done" to "oh this doesn't exist anymore in the jakarta namespace, good luck!"

Having a canonical would mean that there are precise actions that we can take to fix these issues, but in reality the issues are a bit more whack-a-mole than you might realize.

In general it's smooth, but people don't ask questions about the smooth parts.

2
  • I was mainly intending for this canonical to be used for questions where the OP doesn't realize it's a Java EE vs Jakarta EE problem but I get your point.
    – dan1st
    Nov 17 at 7:20
  • Yeah, migrating away from the javax.* namespace in own code is the simple part, most parts are in jakartaee-api or separate libs like jakarta-mail. The fun begins after that with 3rdparty libs which also need to be jakarta-aware, e.g. jackson. For nightmare difficulty, add a separate appserver-based component like Camunda 7 which has its own incompatible dependencies. So I agree a canonical wouldn't be able to describe a full fix... otoh, a full fix would be "too broad" for SO, so a canonical which just states that one needs to do a migration might be valuable as a close target.
    – l4mpi
    Nov 17 at 11:14
0

After seeing more upvotes than downvotes on the question (+22/-1 at the time of writing), I have created the canonical.

Feel free to suggest improvements or edit it yourself if you think there is something missing or inaccurate.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .