NoClassDefFoundError jakarta/servlet/http/HttpServletResponse when starting Solr

667 Views Asked by At

Using Solr 8.11.2 (Jetty 9.4) with Java 11, we're having the following error at startup:

java.lang.NoClassDefFoundError: jakarta/servlet/http/HttpServletResponse

java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
        at org.eclipse.jetty.start.Main.start(Main.java:491)
        at org.eclipse.jetty.start.Main.main(Main.java:77)
Caused by: java.lang.NoClassDefFoundError: jakarta/servlet/http/HttpServletResponse
        at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
...
        at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.construct(XmlConfiguration.java:1031)
...
        at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:380)
        at org.eclipse.jetty.xml.XmlConfiguration.lambda$main$3(XmlConfiguration.java:1893)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1857)
        ... 7 more
Caused by: java.lang.ClassNotFoundException: jakarta.servlet.http.HttpServletResponse
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:476)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        ... 23 more

Even though we are aware of the javax.* to jakarta.* move, we don't understand why the jakarta.* class is even trying to be loaded.

Jetty 9.4 is still using/providing javax.*.

The jetty.xml configuration file that seems to be causing the failure doesn't have any reference to jakarta either.

1

There are 1 best solutions below

2
Gaël J On

The issue was actually caused by external libraries we add to Solr: using logback 1.2 was working fine but upgrading to 1.4 was the root cause of the issue above.

This is because logback 1.4 targets jakarta.* and we are referencing a logback class in the Jetty configuration for access logs.

Not upgrading to logback 1.4 but only 1.3 is the right solution.