title: How to deploy a Spring-Boot-Webflux application to Tomcat standalone server?
body: <p>A normal spring-web application can be deployed to <code>tomcat</code> standalone as <code>war</code> file as follows:</p>
  <pre><code>@SpringBootApplication
  public class MyApplication extends SpringBootServletInitializer {
  
      @Override
      protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
          return application.sources(MyApplication.class);
      }
  
      public static void main(String[] args) {
          SpringApplication.run(MyApplication.class, args);
      }
  }
  </code></pre>
  <p>Question: how can I deploy such an application after migrating to <code>spring-webflux</code> to tomcat?</p>
  <p>Docs say:
  <a href="https://docs.spring.io/spring-framework/docs/current/reference/html/web-reactive.html#webflux-httphandler" rel="nofollow noreferrer">https://docs.spring.io/spring-framework/docs/current/reference/html/web-reactive.html#webflux-httphandler</a></p>
  <blockquote>
  <p>To deploy as a WAR to any Servlet 3.1+ container, you can extend and
  include AbstractReactiveWebInitializer in the WAR. That class wraps an
  HttpHandler with ServletHttpHandlerAdapter and registers that as a
  Servlet.</p>
  </blockquote>
  <p>So but there is no example how to.</p>
  <p>I tried as follows, which gives an exception:</p>
  <pre><code>@SpringBootApplication
  public class MyApplication extends AbstractReactiveWebInitializer {
  
      @Override
      protected Class&lt;?&gt;[] getConfigClasses() {
          return new Class[] {MyApplication.class};
      }
  
      public static void main(String[] args) {
          SpringApplication.run(MyApplication.class, args);
      }
  }
  </code></pre>
  <p>Result:</p>
  <pre><code>MyApplication.java:13:8
  java: cannot access javax.servlet.ServletException
    class file for javax.servlet.ServletException not found
  </code></pre>