javax.faces.webapp.FacesServlet is not assignable to javax.servlet.Servlet , jakarta.servlet.Servlet

Viewed 397

I tried to set up a JSF project in Intellij. I noticed that the JSF components are not being rendered, so I started checking the things listed in this post. Here is my web.xml:

<?xml version = "1.0" encoding = "UTF-8"?>
<web-app xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
         xmlns = "http://java.sun.com/xml/ns/javaee"
         xmlns:web = "http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         xsi:schemaLocation = "http://java.sun.com/xml/ns/javaee
   http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         id = "WebApp_ID" version="2.5">

    <welcome-file-list>
        <welcome-file>faces/home.xhtml</welcome-file>
    </welcome-file-list>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>

    ...
</web-app>

My project compiles but IntelliJ highlights the servlet: enter image description here

I also include jsf in my pom.xml, in case that is relevant:

<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-api</artifactId>
    <version>2.2.20</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-impl</artifactId>
    <version>2.2.20</version>
    <scope>provided</scope>
</dependency>

Any idea what the problem here could be?

1 Answers

In my case I forgot to write:

extends jakarta.servlet.http.HttpServlet

For a class in my .java file.

Related