title: Spring reactive security - Type javax.servlet.Filter not present
body: <p>Trying to implement reactive spring security.</p>
  
  <p><strong>Pom dependencies,</strong></p>
  
  <pre><code>&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;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-webflux&lt;/artifactId&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p><strong>WebSecurityConfig,</strong></p>
  
  <pre><code>@Configuration
  @EnableWebFluxSecurity
  @EnableGlobalMethodSecurity(prePostEnabled = true)
  public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
      @Autowired
      private AuthenticationManager authenticationManager;
  
      @Autowired
      private ServerSecurityContextRepository securityContextRepository;
  
      @Bean
      public SecurityWebFilterChain securitygWebFilterChain(ServerHttpSecurity http) {
          return http.exceptionHandling().authenticationEntryPoint((swe, e) -&gt; {
              return Mono.fromRunnable(() -&gt; {
                  swe.getResponse().setStatusCode(HttpStatus.UNAUTHORIZED);
              });
          }).accessDeniedHandler((swe, e) -&gt; {
              return Mono.fromRunnable(() -&gt; {
                  swe.getResponse().setStatusCode(HttpStatus.FORBIDDEN);
              });
          }).and().csrf().disable().formLogin().disable().httpBasic().disable()
                  .authenticationManager(authenticationManager).securityContextRepository(securityContextRepository)
                  .authorizeExchange().pathMatchers(HttpMethod.OPTIONS).permitAll().pathMatchers("/login").permitAll()
                  .anyExchange().authenticated().and().build();
      }
  
      @Bean
      public PBKDF2Encoder passwordEncoder() {
          return new PBKDF2Encoder();
      }
  
  }
  </code></pre>
  
  <p>Not sure why getting typenotpresentexception error,</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webSecurityConfig' defined in file [/Users/samiksha/Documents/Team/Webinar/workspace/webinar-service/target/classes/com/webinar/service/spring/security/WebSecurityConfig.class]: Post-processing of merged bean definition failed; nested exception is java.lang.TypeNotPresentException: Type javax.servlet.Filter not present
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:572) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:882) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:67) ~[spring-boot-2.3.0.BUILD-SNAPSHOT.jar:2.3.0.BUILD-SNAPSHOT]
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.0.BUILD-SNAPSHOT.jar:2.3.0.BUILD-SNAPSHOT]
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[spring-boot-2.3.0.BUILD-SNAPSHOT.jar:2.3.0.BUILD-SNAPSHOT]
      at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.3.0.BUILD-SNAPSHOT.jar:2.3.0.BUILD-SNAPSHOT]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.3.0.BUILD-SNAPSHOT.jar:2.3.0.BUILD-SNAPSHOT]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~[spring-boot-2.3.0.BUILD-SNAPSHOT.jar:2.3.0.BUILD-SNAPSHOT]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.3.0.BUILD-SNAPSHOT.jar:2.3.0.BUILD-SNAPSHOT]
      at com.webinar.service.ServiceApplication.main(ServiceApplication.java:22) ~[classes/:na]
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
      at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
      at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.3.0.BUILD-SNAPSHOT.jar:2.3.0.BUILD-SNAPSHOT]
  Caused by: java.lang.TypeNotPresentException: Type javax.servlet.Filter not present
      at java.base/sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:117) ~[na:na]
      at java.base/sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125) ~[na:na]
      at java.base/sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49) ~[na:na]
      at java.base/sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68) ~[na:na]
      at java.base/sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138) ~[na:na]
      at java.base/sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49) ~[na:na]
      at java.base/sun.reflect.generics.repository.ClassRepository.computeSuperInterfaces(ClassRepository.java:117) ~[na:na]
      at java.base/sun.reflect.generics.repository.ClassRepository.getSuperInterfaces(ClassRepository.java:95) ~[na:na]
      at java.base/java.lang.Class.getGenericInterfaces(Class.java:1156) ~[na:na]
      at org.springframework.core.ResolvableType.getInterfaces(ResolvableType.java:492) ~[spring-core-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.core.ResolvableType.as(ResolvableType.java:450) ~[spring-core-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.core.ResolvableType.as(ResolvableType.java:451) ~[spring-core-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.core.ResolvableType.as(ResolvableType.java:456) ~[spring-core-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.core.ResolvableType.as(ResolvableType.java:456) ~[spring-core-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.core.ResolvableType.forMethodParameter(ResolvableType.java:1326) ~[spring-core-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.core.ResolvableType.forMethodParameter(ResolvableType.java:1309) ~[spring-core-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.core.ResolvableType.forMethodParameter(ResolvableType.java:1276) ~[spring-core-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.core.ResolvableType.forMethodParameter(ResolvableType.java:1266) ~[spring-core-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.core.BridgeMethodResolver.isResolvedTypeMatch(BridgeMethodResolver.java:157) ~[spring-core-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.core.BridgeMethodResolver.isBridgeMethodFor(BridgeMethodResolver.java:141) ~[spring-core-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.core.BridgeMethodResolver.searchCandidates(BridgeMethodResolver.java:120) ~[spring-core-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.core.BridgeMethodResolver.findBridgedMethod(BridgeMethodResolver.java:82) ~[spring-core-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.lambda$buildPersistenceMetadata$1(PersistenceAnnotationBeanPostProcessor.java:439) ~[spring-orm-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:324) ~[spring-core-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.buildPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:438) ~[spring-orm-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:409) ~[spring-orm-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:336) ~[spring-orm-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:1094) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:569) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      ... 21 common frames omitted
  Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter
      at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602) ~[na:na]
      at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
      at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
      at java.base/java.lang.Class.forName0(Native Method) ~[na:na]
      at java.base/java.lang.Class.forName(Class.java:427) ~[na:na]
      at java.base/sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114) ~[na:na]
      ... 49 common frames omitted
  </code></pre>