javax.servlet:servlet-api is not provided transitively by the vaadin(-core)

Hello community,

in my project, I am using the following dependency:

<dependency>
  <groupId>com.vaadin</groupId>
  <artifactId>vaadin-core</artifactId>
</dependency>

The version of this and every other vaadin maven dependency is managed by the vaadin-spring-bom-14-3.2.pom. If you include vaadin-core, you automatically get the flow-server maven dependency, which includes the class VaadinSession. VaadinSession implements HttpSessionBindingListener from the maven dependency javax.servlet:servlet-api. The problem I have is, that the servlet-api dependency is not provided transitively by having the flow-server dependency. If I want to use the VaadinSession class, I have to manually add

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
</dependency>

to the pom of the corresponding maven module. Otherwise I get and error on compile time: “Cannot access javax.servlet.http.HttpSessionBindingListener”. My question: did I mess up somewhere or is the dependency really missing when adding the vaadin(-core) dependency to the pom.xml.

Thanks in advance,
Eric

The Servlet API dependency needs to be declared with <scope>provided</scope> to prevent problems when the application is deployed. For this reason, it cannot be included as a transitive dependency but should instead be included in the application’s own pom.xml.

This is supposed to be a part of the example projects that you would get from e.g. vaadin.com/start. If you got the foundation of your project from any official source but it didn’t have a servlet dependency declared, then please let us know from where you got it so that we can ensure others won’t face the same problems.

As a final note, your example with version 2.5 won’t work properly since Vaadin requires version 3.1 or newer of the Servlet API.

Thanks for the clarification Leif.