Skip to content
Advertisement

Wildfly Undertow: jakarta.servlets.Servlet does not implement javax.servlet.Servlet

I am trying to migrate some Servlets from javax libraries to jakarta. Changes are pretty straightforward but, when I try to run them on Wildfly 23, I get this error message:

Servlet JAX-WS-Service of type class com.sun.xml.ws.transport.http.servlet.WSServlet does not implement javax.servlet.Servlet

This happens for this servlet (used for JAXWS, but that’s not the point) but also with my own servlets, which look like this:

import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

@WebServlet(name = "entrada", loadOnStartup = 1)
public class ServletEntrada extends HttpServlet

I’m using Jakarta servlet-api version 5.0.0. The servlets are declared in the web.xml file like this:

<servlet>
    <servlet-name>ServletEntrada</servlet-name>
    <servlet-class>com.telventi.framework.web.ServletEntrada</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

If I leave this declaration on web.xml, I get the error I mention, ServletEntrada does not implement javax.servlet.Servlet.

If I remove this declaration from the web.xml file, the servlet is not deployed. Even though, it has the @WebServlet annotation, which should make the Servlet automatically discovered by Wildfly.

I guess undertow checks for every servlet declared in web.xml file if they extend javax.servlet.Servlet, but of course the jakarta HttpServlet extends jakarta.servlets.Servlet, not javax.servlets.Servlet.

Am I doing anything wrong?

Best regards.

Advertisement

Answer

You need to use WildFly Preview for JakartaEE 9 support, the default WildFly distribution is still Java EE / Jakarta EE 8

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement