title: Spring Boot war file on tomcat: errorPageFilter cannot be cast to TomcatEmbeddedServletContainerFactory
body: <p>I'm trying to convert a simple Spring Boot app into a war file for deployment to my tomcat server but I keep on getting this error:</p>
  
  <pre><code>Caused by: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'errorPageFilter': Initialization of bean failed; nested exception is java.lang.ClassCastException: org.springframework.boot.context.web.ErrorPageFilter cannot be cast to org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
  </code></pre>
  
  <p>This Spring Boot app works perfectly when I run it as a jar but if I create a war, it gives me errors. As far as I can tell, I followed the Spring guide for this perfectly: <a href="http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file" rel="nofollow">http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file</a></p>
  
  <p>This is my application class:</p>
  
  <pre><code>@Configuration
  @EnableWebMvc
  @ComponentScan({"XXX"})
  @EnableAutoConfiguration
  @EnableConfigurationProperties
  @SpringBootApplication
  @EnableAsync
  public class Application extends SpringBootServletInitializer {
  
      @Override
      protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
          return application.sources(Application.class);
      }
  
      public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  
  }
  </code></pre>
  
  <p>This is my build.gradle:</p>
  
  <pre><code>buildscript {
      ext {
          springBootVersion = '1.2.6.RELEASE'
      }
      repositories {
          maven { url "http://repo.spring.io/libs-release" }
          maven { url "http://repo.spring.io/libs-snapshot" }
          mavenCentral()
          mavenLocal()
      }
      dependencies {
          classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
      }
  }
  
  apply plugin: 'war'
  apply plugin: 'java'
  apply plugin: 'idea'
  apply plugin: 'spring-boot'
  apply plugin: 'application'
  
  war {
      archiveName 'hello-gradle.war'
  }
  
  configurations {
      providedRuntime
  }
  
  compileJava {
      targetCompatibility = 1.8
      sourceCompatibility = 1.8
  }
  
  mainClassName = "XXX.Application"
  
  repositories {
      mavenCentral()
      maven { url "http://repo.spring.io/libs-release" }
      maven { url "http://repo.spring.io/libs-snapshot" }
      maven { url "http://maven.springframework.org/milestone" }
  }
  
  dependencies {
  
      compile fileTree(dir: 'libs', include: ['*.jar'])
  
      compile 'com.fasterxml.jackson.core:jackson-databind:2.3.2'
      compile 'com.fasterxml.jackson.core:jackson-core:2.5.3'
  
      compile 'org.springframework.boot:spring-boot-starter-web'
      compile 'org.springframework.boot:spring-boot-starter-tomcat'
      compile 'org.springframework.boot:spring-boot-starter-security'
      compile 'org.springframework.boot:spring-boot-starter-actuator'
      compile 'org.springframework.boot:spring-boot-starter-aop'
      compile 'org.mongodb:mongo-java-driver:3.1.0'
      compile 'org.springframework.data:spring-data-mongodb:1.8.0.RELEASE'
      compile("org.springframework:spring-context-support")
  
      providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
  }
  
  task wrapper(type: Wrapper) {
      gradleVersion = '2.8'
  }
  </code></pre>
  
  <p>This is my catalina.log:</p>
  
  <pre><code>&gt; 12-Dec-2015 14:53:54.921 INFO [localhost-startStop-1]
  &gt; org.apache.catalina.startup.HostConfig.deployWAR Deployment of web
  &gt; application archive C:\Tomcat8\webapps\hello-gradle.war has finished
  &gt; in 4,900 ms 12-Dec-2015 14:53:54.921 INFO [localhost-startStop-1]
  &gt; org.apache.catalina.startup.HostConfig.deployDirectory Deploying web
  &gt; application directory C:\Tomcat8\webapps\docs 12-Dec-2015 14:53:54.993
  &gt; INFO [localhost-startStop-1]
  &gt; org.apache.catalina.startup.HostConfig.deployDirectory Deployment of
  &gt; web application directory C:\Tomcat8\webapps\docs has finished in 72
  &gt; ms 12-Dec-2015 14:53:54.993 INFO [localhost-startStop-1]
  &gt; org.apache.catalina.startup.HostConfig.deployDirectory Deploying web
  &gt; application directory C:\Tomcat8\webapps\examples 12-Dec-2015
  &gt; 14:53:55.239 INFO [localhost-startStop-1]
  &gt; org.apache.catalina.startup.HostConfig.deployDirectory Deployment of
  &gt; web application directory C:\Tomcat8\webapps\examples has finished in
  &gt; 246 ms 12-Dec-2015 14:53:55.239 INFO [localhost-startStop-1]
  &gt; org.apache.catalina.startup.HostConfig.deployDirectory Deploying web
  &gt; application directory C:\Tomcat8\webapps\host-manager 12-Dec-2015
  &gt; 14:53:55.262 INFO [localhost-startStop-1]
  &gt; org.apache.catalina.startup.HostConfig.deployDirectory Deployment of
  &gt; web application directory C:\Tomcat8\webapps\host-manager has finished
  &gt; in 23 ms 12-Dec-2015 14:53:55.262 INFO [localhost-startStop-1]
  &gt; org.apache.catalina.startup.HostConfig.deployDirectory Deploying web
  &gt; application directory C:\Tomcat8\webapps\manager 12-Dec-2015
  &gt; 14:53:55.283 INFO [localhost-startStop-1]
  &gt; org.apache.catalina.startup.HostConfig.deployDirectory Deployment of
  &gt; web application directory C:\Tomcat8\webapps\manager has finished in
  &gt; 21 ms 12-Dec-2015 14:53:55.284 INFO [localhost-startStop-1]
  &gt; org.apache.catalina.startup.HostConfig.deployDirectory Deploying web
  &gt; application directory C:\Tomcat8\webapps\ROOT 12-Dec-2015 14:53:55.316
  &gt; INFO [localhost-startStop-1]
  &gt; org.apache.catalina.startup.HostConfig.deployDirectory Deployment of
  &gt; web application directory C:\Tomcat8\webapps\ROOT has finished in 32
  &gt; ms 12-Dec-2015 14:53:55.328 INFO [main]
  &gt; org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler
  &gt; ["http-apr-8080"] 12-Dec-2015 14:53:55.337 INFO [main]
  &gt; org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler
  &gt; ["ajp-apr-8009"] 12-Dec-2015 14:53:55.340 INFO [main]
  &gt; org.apache.catalina.startup.Catalina.start Server startup in 5354 ms
  &gt; 12-Dec-2015 14:54:25.834 INFO
  &gt; [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
  &gt; org.apache.catalina.startup.HostConfig.undeploy Undeploying context
  &gt; [/hello-gradle] 12-Dec-2015 14:54:25.847 SEVERE
  &gt; [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
  &gt; org.apache.catalina.startup.ExpandWar.deleteDir
  &gt; [C:\Tomcat8\webapps\hello-gradle\WEB-INF\lib] could not be completely
  &gt; deleted. The presence of the remaining files may cause problems
  &gt; 12-Dec-2015 14:54:25.848 SEVERE
  &gt; [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
  &gt; org.apache.catalina.startup.ExpandWar.deleteDir
  &gt; [C:\Tomcat8\webapps\hello-gradle\WEB-INF] could not be completely
  &gt; deleted. The presence of the remaining files may cause problems
  &gt; 12-Dec-2015 14:54:25.848 SEVERE
  &gt; [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
  &gt; org.apache.catalina.startup.ExpandWar.deleteDir
  &gt; [C:\Tomcat8\webapps\hello-gradle] could not be completely deleted. The
  &gt; presence of the remaining files may cause problems 12-Dec-2015
  &gt; 14:54:25.849 SEVERE
  &gt; [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
  &gt; org.apache.catalina.startup.ExpandWar.delete
  &gt; [C:\Tomcat8\webapps\hello-gradle] could not be completely deleted. The
  &gt; presence of the remaining files may cause problems 12-Dec-2015
  &gt; 14:54:25.851 INFO [localhost-startStop-2]
  &gt; org.apache.catalina.startup.HostConfig.deployDirectory Deploying web
  &gt; application directory C:\Tomcat8\webapps\hello-gradle 12-Dec-2015
  &gt; 14:54:27.196 INFO [localhost-startStop-2]
  &gt; org.apache.catalina.startup.HostConfig.deployDirectory Deployment of
  &gt; web application directory C:\Tomcat8\webapps\hello-gradle has finished
  &gt; in 1,345 ms 12-Dec-2015 14:54:35.176 INFO [http-apr-8080-exec-12]
  &gt; org.apache.catalina.startup.HostConfig.undeploy Undeploying context
  &gt; [/hello-gradle] 12-Dec-2015 14:54:35.203 INFO [http-apr-8080-exec-12]
  &gt; org.apache.catalina.startup.HostConfig.deployWAR Deploying web
  &gt; application archive C:\Tomcat8\webapps\hello-gradle.war 12-Dec-2015
  &gt; 14:54:39.295 SEVERE [http-apr-8080-exec-12]
  &gt; org.apache.catalina.core.ContainerBase.addChildInternal
  &gt; ContainerBase.addChild: start:  
  &gt; org.apache.catalina.LifecycleException: Failed to start component
  &gt; [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/hello-gradle]]
  &gt;   at
  &gt; org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
  &gt;   at
  &gt; org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
  &gt;   at
  &gt; org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
  &gt;   at
  &gt; org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
  &gt;   at
  &gt; org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945)
  &gt;   at
  &gt; org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:466)
  &gt;   at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1583)
  &gt;   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at
  &gt; sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  &gt;   at
  &gt; sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  &gt;   at java.lang.reflect.Method.invoke(Method.java:497)     at
  &gt; org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
  &gt;   at
  &gt; com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
  &gt;   at
  &gt; com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
  &gt;   at
  &gt; org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1460)
  &gt;   at
  &gt; org.apache.catalina.manager.HTMLManagerServlet.upload(HTMLManagerServlet.java:288)
  &gt;   at
  &gt; org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:209)
  &gt;   at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)     at
  &gt; javax.servlet.http.HttpServlet.service(HttpServlet.java:729)  at
  &gt; org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
  &gt;   at
  &gt; org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  &gt;   at
  &gt; org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:136)
  &gt;   at
  &gt; org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  &gt;   at
  &gt; org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  &gt;   at
  &gt; org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  &gt;   at
  &gt; org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  &gt;   at
  &gt; org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  &gt;   at
  &gt; org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
  &gt;   at
  &gt; org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  &gt;   at
  &gt; org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  &gt;   at
  &gt; org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
  &gt;   at
  &gt; org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
  &gt;   at
  &gt; org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
  &gt;   at
  &gt; org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
  &gt;   at
  &gt; org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
  &gt;   at
  &gt; org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
  &gt;   at
  &gt; org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
  &gt;   at
  &gt; org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:521)
  &gt;   at
  &gt; org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096)
  &gt;   at
  &gt; org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674)
  &gt;   at
  &gt; org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2500)
  &gt;   at
  &gt; org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2489)
  &gt;   at
  &gt; java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  &gt;   at
  &gt; java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  &gt;   at
  &gt; org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  &gt;   at java.lang.Thread.run(Thread.java:745) Caused by:
  &gt; org.springframework.context.ApplicationContextException: Unable to
  &gt; start embedded container; nested exception is
  &gt; org.springframework.beans.factory.BeanCreationException: Error
  &gt; creating bean with name 'errorPageFilter': Initialization of bean
  &gt; failed; nested exception is java.lang.ClassCastException:
  &gt; org.springframework.boot.context.web.ErrorPageFilter cannot be cast to
  &gt; org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
  &gt;   at
  &gt; org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133)
  &gt;   at
  &gt; org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474)
  &gt;   at
  &gt; org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
  &gt;   at
  &gt; org.springframework.boot.SpringApplication.refresh(SpringApplication.java:687)
  &gt;   at
  &gt; org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
  &gt;   at
  &gt; org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:133)
  &gt;   at
  &gt; org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:124)
  &gt;   at
  &gt; org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:81)
  &gt;   at
  &gt; org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175)
  &gt;   at
  &gt; org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5244)
  &gt;   at
  &gt; org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  &gt;   ... 45 more Caused by:
  &gt; org.springframework.beans.factory.BeanCreationException: Error
  &gt; creating bean with name 'errorPageFilter': Initialization of bean
  &gt; failed; nested exception is java.lang.ClassCastException:
  &gt; org.springframework.boot.context.web.ErrorPageFilter cannot be cast to
  &gt; org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
  &gt;   at
  &gt; org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
  &gt;   at
  &gt; org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
  &gt;   at
  &gt; org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
  &gt;   at
  &gt; org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
  &gt;   at
  &gt; org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
  &gt;   at
  &gt; org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
  &gt;   at
  &gt; org.springframework.boot.context.embedded.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:209)
  &gt;   at
  &gt; org.springframework.boot.context.embedded.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:165)
  &gt;   at
  &gt; org.springframework.boot.context.embedded.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:160)
  &gt;   at
  &gt; org.springframework.boot.context.embedded.ServletContextInitializerBeans.addAdaptableBeans(ServletContextInitializerBeans.java:143)
  &gt;   at
  &gt; org.springframework.boot.context.embedded.ServletContextInitializerBeans.&lt;init&gt;(ServletContextInitializerBeans.java:74)
  &gt;   at
  &gt; org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getServletContextInitializerBeans(EmbeddedWebApplicationContext.java:234)
  &gt;   at
  &gt; org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.selfInitialize(EmbeddedWebApplicationContext.java:221)
  &gt;   at
  &gt; org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.access$000(EmbeddedWebApplicationContext.java:84)
  &gt;   at
  &gt; org.springframework.boot.context.embedded.EmbeddedWebApplicationContext$1.onStartup(EmbeddedWebApplicationContext.java:206)
  &gt;   at
  &gt; org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:162)
  &gt;   at
  &gt; org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
  &gt;   ... 55 more Caused by: java.lang.ClassCastException:
  &gt; org.springframework.boot.context.web.ErrorPageFilter cannot be cast to
  &gt; org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
  &gt;   at
  &gt; com.futureprocessing.spring.ContainerConfiguration$1.customize(ContainerConfiguration.java:34)
  &gt;   at
  &gt; org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor.postProcessBeforeInitialization(EmbeddedServletContainerCustomizerBeanPostProcessor.java:67)
  &gt;   at
  &gt; org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor.postProcessBeforeInitialization(EmbeddedServletContainerCustomizerBeanPostProcessor.java:54)
  &gt;   at
  &gt; org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
  &gt;   at
  &gt; org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
  &gt;   at
  &gt; org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
  &gt;   ... 71 more
  &gt; 
  &gt; 12-Dec-2015 14:54:39.321 SEVERE [http-apr-8080-exec-12]
  &gt; org.apache.catalina.startup.HostConfig.deployWAR Error deploying web
  &gt; application archive C:\Tomcat8\webapps\hello-gradle.war 
  &gt; java.lang.IllegalStateException: ContainerBase.addChild: start:
  &gt; org.apache.catalina.LifecycleException: Failed to start component
  &gt; [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/hello-gradle]]
  &gt;   at
  &gt; org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:729)
  &gt;   at
  &gt; org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
  &gt;   at
  &gt; org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
  &gt;   at
  &gt; org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945)
  &gt;   at
  &gt; org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:466)
  &gt;   at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1583)
  &gt;   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at
  &gt; sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  &gt;   at
  &gt; sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  &gt;   at java.lang.reflect.Method.invoke(Method.java:497)     at
  &gt; org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
  &gt;   at
  &gt; com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
  &gt;   at
  &gt; com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
  &gt;   at
  &gt; org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1460)
  &gt;   at
  &gt; org.apache.catalina.manager.HTMLManagerServlet.upload(HTMLManagerServlet.java:288)
  &gt;   at
  &gt; org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:209)
  &gt;   at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)     at
  &gt; javax.servlet.http.HttpServlet.service(HttpServlet.java:729)  at
  &gt; org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
  &gt;   at
  &gt; org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  &gt;   at
  &gt; org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:136)
  &gt;   at
  &gt; org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  &gt;   at
  &gt; org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  &gt;   at
  &gt; org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  &gt;   at
  &gt; org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  &gt;   at
  &gt; org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  &gt;   at
  &gt; org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
  &gt;   at
  &gt; org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  &gt;   at
  &gt; org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  &gt;   at
  &gt; org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
  &gt;   at
  &gt; org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
  &gt;   at
  &gt; org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
  &gt;   at
  &gt; org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
  &gt;   at
  &gt; org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
  &gt;   at
  &gt; org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
  &gt;   at
  &gt; org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
  &gt;   at
  &gt; org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:521)
  &gt;   at
  &gt; org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096)
  &gt;   at
  &gt; org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674)
  &gt;   at
  &gt; org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2500)
  &gt;   at
  &gt; org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2489)
  &gt;   at
  &gt; java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  &gt;   at
  &gt; java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  &gt;   at
  &gt; org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  &gt;   at java.lang.Thread.run(Thread.java:745)
  &gt; 
  &gt; 12-Dec-2015 14:54:39.327 INFO [http-apr-8080-exec-12]
  &gt; org.apache.catalina.startup.HostConfig.deployWAR Deployment of web
  &gt; application archive C:\Tomcat8\webapps\hello-gradle.war has finished
  &gt; in 4,123 ms
  </code></pre>
  
  <p>It does say that the error occurred in my java file called <code>ContainerConfiguration.java</code>:</p>
  
  <pre><code>@Configuration
  public class ContainerConfiguration {
  
      @Bean
      EmbeddedServletContainerCustomizer containerCustomizer(
              //all taken from the application.properties file
              @Value("${keystore.file}") String keystoreFile,
              @Value("${server.port}") final String serverPort,
              @Value("${keystore.pass}") final String keystorePass)
              throws Exception {
  
          // This is boiler plate code to setup https on embedded Tomcat
          // with Spring Boot:
  
          final String absoluteKeystoreFile = new File(keystoreFile)
                  .getAbsolutePath();
  
          return new EmbeddedServletContainerCustomizer() {
              @Override
              public void customize(ConfigurableEmbeddedServletContainer container) {
                  TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
                  tomcat.addConnectorCustomizers(connector -&gt; {
                      connector.setPort(Integer.parseInt(serverPort));
                      connector.setSecure(true);
                      connector.setScheme("https");
  
                      Http11NioProtocol proto = (Http11NioProtocol) connector
                              .getProtocolHandler();
                      proto.setSSLEnabled(true);
  
                      proto.setKeystoreFile(absoluteKeystoreFile);
                      proto.setKeystorePass(keystorePass);
                      proto.setKeystoreType("JKS");
                      proto.setKeyAlias("abcd"); 
                  });
              }
          };
      }
  }
  </code></pre>
  
  <p>The error is on this line:</p>
  
  <pre><code>     tomcat.addConnectorCustomizers(connector -&gt; {
                  connector.setPort(Integer.parseInt(serverPort));
                  connector.setSecure(true);
                  connector.setScheme("https");
  </code></pre>
  
  <p>I don't get how <code>errorPageFilter</code> is casted to <code>TomcatEmbeddedServletContainerFactory</code>?</p>
  
  <p>Does anyone know how I can fix this error?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I have also create a simple SpringBoot test app to demonstrate this error as well , you can find it here: <a href="https://github.com/Winghin2517/testSpringBootTomcat" rel="nofollow">https://github.com/Winghin2517/testSpringBootTomcat</a></p>
  
  <p><strong>There are only two classes in the github repo:</strong></p>
  
  <ol>
  <li>ContainerConfiguration - where the offensive class is sitting.</li>
  <li>DemoApplication - the main method sits here</li>
  </ol>
  
  <p>If you comment out the ContainerConfiguration and build a war file then upload it to a tomcat server, it works perfectly.
  If you uncomment out the ContainerConfiguration and build the war file and upload it, you will get the error.</p>