ring-clojure / ring

Clojure HTTP server abstraction
MIT License
3.78k stars 520 forks source link

Build uberwar with jakarta servlet #517

Open madoxas opened 1 day ago

madoxas commented 1 day ago

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 .

weavejester commented 1 day ago

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.

madoxas commented 22 hours ago

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?

weavejester commented 19 hours ago

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.