Hello. After Tomcat upgrade from 9.x to 10.x all K...
# ktor
r
Hello. After Tomcat upgrade from 9.x to 10.x all Ktor services are crashing with
"NoClassDefFoundError: javax/servlet/http/HttpServlet"
and
Error instantiating servlet class [io.ktor.server.servlet.ServletApplicationEngine]
Do I need to change some settings in web.xml?
e
Hey! Could you tell me what ktor dependency you’re using for tomcat?
r
For development purposes we are using Netty, so we didn't need any dependency for tomcat. We are only using War task to build .war file which is send to Tomcat on production
e
Could you tell me if you’re using any ktor servlet dependency?
r
Sure, I'll check. Its a big project with many custom dependencies, so I'll need a minute
🙏 1
We use only "io.ktorktor server servlet2.2.1"
I searched ktor docs for "servlet" and I think I found solution. For newer tomcat I need to include "io.ktor:ktor-server-servlet-jakarta" right?
e
Yep! The new version is supported with a different module for backward compatibility. Could you try it? 🙂
r
Yes, it is working in Tomcat 10, but I see that it has no backwards compability? On Tomcat 9 jakarta is crashing, so we have to update Tomcat and all wars in the same time?
e
You can try updating it in a module-by-module way
r
Could you elaborate? I have 5 applications working on servlet and Tomcat 9. We need to update Tomcat to version 10, is there any way to do code changes on old Tomcat and then just replace Tomcat?
e
It depends on how the project is structured. If they all in a different modules, you can try make per-module update. Otherwise, you can try adding both dependencies. It will need to explicitly specify imports depending on the version of tomcat is used by specific app
r
All the apps are on the same server and same single instance of Tomcat, so I don't know how to change just one of them. Adding both dependencies should work on Tomcat 9 and Tomcat 10? Because I also need to change configuration in web.xml
Maybe we will try to create two instances of Tomcat and try to migrate with it. Any way, thanks for help, I ll try to figure this out
e
Splitting is a good idea! I’m not sure if it will work on a single instance