title: Cannot access javax.servlet.Filter; class file for javax.servlet.Filter not found
body: <p>I am trying to implement OAuth2 AuthorizationServer as described in this <a href="https://developer.okta.com/blog/2019/03/12/oauth2-spring-security-guide#create-an-oauth-20-server" rel="noreferrer">article</a> but I keep getting the error below.
  For a spring security config:</p>
  
  <pre><code>import org.springframework.beans.factory.annotation.Value;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.core.annotation.Order;
  import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
  import org.springframework.security.config.annotation.web.builders.HttpSecurity;
  import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
  import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
  
  @Configuration
  @Order(1)
  class SecurityConfig extends WebSecurityConfigurerAdapter {
  
      @Value("${user.oauth.user.username}")
      private String username;
      @Value("${user.oauth.user.password}")
      private String password;
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http.requestMatchers()
                  .antMatchers("/login", "/oauth/authorize")
                  .and()
                  .authorizeRequests()
                  .anyRequest().authenticated()
                  .and()
                  .formLogin().permitAll();
      }
  
      @Override
      protected void configure(AuthenticationManagerBuilder auth) throws Exception {
          auth.inMemoryAuthentication()
                  .withUser(username)
                  .password(passwordEncoder().encode(password))
                  .roles("USER");
      }
  
      @Bean
      public BCryptPasswordEncoder passwordEncoder() {
          return new BCryptPasswordEncoder();
      }
  }
  </code></pre>
  
  <p>I keep getting this error:</p>
  
  <pre><code>[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project auth-service: Compilation failure
  [ERROR] /home/mcs/auth-service/src/main/java/com/example/authservice/config/SecurityConfig.java:[14,1] cannot access javax.servlet.Filter
  [ERROR] class file for javax.servlet.Filter not found
  </code></pre>
  
  <p>What does it mean and what seems to be wrong?</p>
  
  <p>My pom.xml generated form start.spring.io using the latest M2 release for Spring Boot:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;2.2.0.M2&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
      &lt;groupId&gt;com.example&lt;/groupId&gt;
      &lt;artifactId&gt;auth-service&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;auth-service&lt;/name&gt;
      &lt;description&gt;Authorization service&lt;/description&gt;
  
      &lt;properties&gt;
          &lt;java.version&gt;11&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.okta.spring&lt;/groupId&gt;
              &lt;artifactId&gt;okta-spring-boot-starter&lt;/artifactId&gt;
              &lt;version&gt;1.1.0&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security.oauth&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-oauth2&lt;/artifactId&gt;
              &lt;version&gt;2.3.5.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
              &lt;artifactId&gt;lombok&lt;/artifactId&gt;
              &lt;version&gt;2.6.7&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
      &lt;repositories&gt;
          &lt;repository&gt;
              &lt;id&gt;spring-snapshots&lt;/id&gt;
              &lt;name&gt;Spring Snapshots&lt;/name&gt;
              &lt;url&gt;https://repo.spring.io/snapshot&lt;/url&gt;
              &lt;snapshots&gt;
                  &lt;enabled&gt;true&lt;/enabled&gt;
              &lt;/snapshots&gt;
          &lt;/repository&gt;
          &lt;repository&gt;
              &lt;id&gt;spring-milestones&lt;/id&gt;
              &lt;name&gt;Spring Milestones&lt;/name&gt;
              &lt;url&gt;https://repo.spring.io/milestone&lt;/url&gt;
          &lt;/repository&gt;
      &lt;/repositories&gt;
      &lt;pluginRepositories&gt;
          &lt;pluginRepository&gt;
              &lt;id&gt;spring-snapshots&lt;/id&gt;
              &lt;name&gt;Spring Snapshots&lt;/name&gt;
              &lt;url&gt;https://repo.spring.io/snapshot&lt;/url&gt;
              &lt;snapshots&gt;
                  &lt;enabled&gt;true&lt;/enabled&gt;
              &lt;/snapshots&gt;
          &lt;/pluginRepository&gt;
          &lt;pluginRepository&gt;
              &lt;id&gt;spring-milestones&lt;/id&gt;
              &lt;name&gt;Spring Milestones&lt;/name&gt;
              &lt;url&gt;https://repo.spring.io/milestone&lt;/url&gt;
          &lt;/pluginRepository&gt;
      &lt;/pluginRepositories&gt;
  
  &lt;/project&gt;
  </code></pre>