I have an existing Java REST service I'm trying to upgrade from Tomcat8, Java8, Jersey(2.23), and Weld(2.4.8). I'm using Weld for CDI so that my service classes get instantiated and injected where they're needed in the resource classes. Everything works fine. I have this project defined as a Gradle7 project currently.
Moving to Java17 seems to have required no changes.
Moving to Tomcat9 only required me to change from javax.servlet:javax.servlet-api:3.+ to jakarta.servlet:jakarta.servlet-api:4.+.
I'm getting stuck/confused on Jersey and Weld/CDI.
I'm also confused about javax.ws.rs:javax.ws.rs-api:2.+ vs jakarta.ws.rs:jakarta.ws.rs-api:3.+. I'm pretty sure this is related to Jersey though and only requires me to switch my imports from javax to jakarta.
Any direction would be greatly appreciated since I feel like I'm just spinning at this point.
As Java EE / Jakarta EE evolved, the version of APIs evolved too. At some point the maven artifact names changed from
javaxtojakarta, and later the java package names moved fromjavatojakarta. And there were two versions of 8.See the Tomcat version matrix. There you can find versions of the servlet supported. From that, one can derive the Jersey, CDI, and Weld versions required. The table might look as follows:
Jersey started to support JDK 17 partially since 2.34, better in 2.35.
So you need:
Please do not use Jersey 2.35, better start with the fixed latest version.