ring
ring copied to clipboard
Build uberwar with jakarta servlet
Hi, how should I build a war archive which would use Jakarta Servlets? Building the war by following documentation does not work. I get the following error when deploying to Tomcat 11:
01-Dec-2024 16:17:55.871 SEVERE [main] org.apache.catalina.core.StandardContext.listenerStart Error configuring application listener of class [hello_world.listener]
java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1027)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
...
Any help would be much appreciated .
My guess is that this is running afoul of the move from javax.servlet to jakarta.servlet.
If you're using Lein-Ring, that project will need to be updated to use jakarta.servlet.ServletContextListener and ring.util.jakarta.servlet, instead of the older javax.servlet.ServletContextListener and ring.util.servlet.
Lein-Ring can either be fixed, or you can create the war manually.
Yes, I was trying to use Lein-Ring to create a war.
Let's assume it will not be updated fast. Do you have some how-to I could follow to create the war myself for the Ring app I have?
Perhaps the easiest way would be to clone Lein-Ring, then do a search and replace for the namespaces and classes I listed above. Replace them with the Jakarta version, then install locally using lein install. If it works, you can submit a pull request with the changes.
Otherwise, a quick search reveals this page. There's likely other tutorials out there as well.