As javax.servlet dependency has been deprecated we are getting tidelift suggestions to upgrade to jakarta.servlet. However, when we update to that we are getting below error -
Error: /apps/runner/_work/jabcd/japp-name/core/pom.xml [0:0]: Class org.ab.web.appname.core.servlet.FetchPDF is not assignable to specified service jakarta.servlet.Servlet
Suggestions on this error asking again to revert back to javax.servlet.
Just checking has anyone encountered this issue before? What solution has been implemented to address this. Pls share your experience. Thanks.
-Nilesh
Solved! Go to Solution.
Views
Replies
Total Likes
Currently the work started to allow the use of jakarta.servlet instead of javax.servlet, but I guess that it will take some time to get offically supported.
This issue commonly occurs when upgrading from javax.servlet to jakarta.servlet. The primary reason is that jakarta.servlet introduces breaking package changes, which require recompiling and updating dependencies accordingly. You can try below steps to resolve this issue:
1. If your project has dependencies that still rely on javax.servlet, they may not be compatible with jakarta.servlet.
2. Your FetchPDF class may still be compiled against javax.servlet.Servlet, causing class incompatibility.
3. Some older servlet containers (e.g., Tomcat 9, Jetty 9) still use javax.servlet. Jakarta Servlet 5+ is only supported from Tomcat 10, Jetty 11, etc.
4. If using Spring Boot, ensure you have updated dependencies properly:
Reference - https://foojay.io/today/migrating-from-java-ee-to-jakarta-ee-with-intellij-idea/
Regards,
1. Ensure Compatibility: AEM uses javax.servlet and may not fully support jakarta.servlet yet, especially in older versions.
2. Revert to javax.servlet: If AEM doesn't support jakarta.servlet, revert to using javax.servlet in your pom.xml:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
3. Update Servlets: If you're using jakarta.servlet, make sure your servlet code uses the correct import:
import jakarta.servlet.Servlet;
4. Check AEM Version: If you're on a version that supports jakarta.servlet, update your servlets accordingly. If not, stick to javax.servlet.
Thanks Amit. I believe AEM does not support jakarta.servlet yet (until version 6.5) as jakarta API is not compatible with OSGI services, hance wanted to check if there has been any workaround to make it work. For now I'll keep using javax api until we have an update from Adobe side to use jakarta api with compatible AEM vesion.
Views
Replies
Total Likes
Currently the work started to allow the use of jakarta.servlet instead of javax.servlet, but I guess that it will take some time to get offically supported.
Thank you for the update. So we will continue using the javax.servlet until jakarta.servlet officially starts supporting it.
Views
Replies
Total Likes
Views
Likes
Replies