title: Spring Boot Runs on Tomcat 8.5.x but not 8.0.37 java.lang.NoClassDefFoundError: org/apache/coyote/UpgradeProtocol
body: <p>relatively new to Spring so I am guessing I am not doing something correctly. I have been converting an older java soap service to spring.  I am able to run it locally on tomcat 8.5 and up, but when I run it on tomcat 8.0.37 (which is what the server I will deploy it to is on) I get the error below. I came across this error in another project, but realized in the other project I was unnecessarily creating a servlet, so once I ripped out the servlet code I was good to go. In this instance I need to create a servlet. The error is looking for "org/apache/coyote/UpgradeProtocol" which is not in Tomcat 8.0.37. Not sure what in my code is trying to use it. Any suggestions are appreciated, thanks.</p>
  
  <p>Tomcat dependencies in pom...</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  &lt;dependencyManagement&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
              &lt;version&gt;2.0.7.RELEASE&lt;/version&gt;
              &lt;type&gt;pom&lt;/type&gt;
              &lt;scope&gt;import&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/dependencyManagement&gt;
  </code></pre>
  
  <p>error...</p>
  
  <blockquote>
    <p>2019-01-17 16:05:12,539 SEVERE Class= org.apache.catalina.core.ContainerBase  Method= addChildInternal  Message= ContainerBase.addChild: start: 
    org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/exampleServices]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:940)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1816)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'containerFactory' defined in class path resource [com/removed/exampleServices/exampleServicesConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory]: Factory method 'containerFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/coyote/UpgradeProtocol
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:591)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1246)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1096)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:548)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
        at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:157)
        at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:137)
        at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:91)
        at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:172)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)</p>
  </blockquote>
  
  <p>config class below, I assume the issue is with how I am creating my TomcatServletWebServerFactory or my ServletRegistrationBean </p>
  
  <pre><code>@ComponentScan({"com.example.exampleservices", "com.example.examplesoapservices"})
  @Configuration
  @EnableAWSF
  public class exampleservicesConfiguration {
  
  
  static {
      // Statically initialize SystemImpl so it doesn't slow down first
      // request
      try {
          SystemImpl.getInstance();
      } catch (exampleException e) {
          throw new RuntimeException(e);
      }
  }
  
  @Bean
  public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
      ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new WSSpringServlet(), "/exampleservicesSOAP/*", "/exampleservicesSOAPV3/*");
      //ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new WSSpringServlet(), "/exampleservicesPort/*", "/exampleservicesPortV3/*");
      servletRegistrationBean.setEnabled(true);
      servletRegistrationBean.setLoadOnStartup(0);
      return servletRegistrationBean;
  }
  
  
  @Bean
  @SneakyThrows
  public SpringBinding springBinding(exampleservicesSOAPImpl exampleservicesSOAPImpl, AWSFHandlers awsfHandlers) throws Exception {
      SpringBinding springBinding = new SpringBinding();
      springBinding.setUrl("/exampleservicesSOAP");
      SpringService springService = new SpringService();
      springService.setBean(exampleservicesSOAPImpl);
      springService.setHandlers(awsfHandlers.getAwsfHandlers());
      springBinding.setService(springService.getObject());
      return springBinding;
  }
  
  @Bean
  @SneakyThrows
  public SpringBinding springBindingV3(exampleservicesSOAPV3Impl exampleservicesSOAPV3Impl, AWSFHandlers awsfHandlers) throws Exception {
      SpringBinding springBinding = new SpringBinding();
      springBinding.setUrl("/exampleservicesSOAPV3");
      SpringService springService = new SpringService();
      springService.setBean(exampleservicesSOAPV3Impl);
      springService.setHandlers(awsfHandlers.getAwsfHandlers());
      springBinding.setService(springService.getObject());
      return springBinding;
  }
  
  @Bean
  public Executor threadPoolTaskExecutor(){
      return new ThreadPoolTaskExecutor();
  }
  
  @Bean
  public TomcatServletWebServerFactory  containerFactory() {
      return new TomcatServletWebServerFactory () {
          protected void customizeConnector(Connector connector) {
              super.customizeConnector(connector);
          }
      };
  }
  
  @Bean
  public Jaxb2Marshaller jaxb2Marshaller() {
      Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
      jaxb2Marshaller.setContextPath(exJAXBContext.JAXB_CONTEXT_PATH);
      return jaxb2Marshaller;
  }
  
  @Bean
  private static JAXBContext initContext() {
      try {
          return JAXBContext.newInstance(BasicServiceComponents.eesvcof.getClass().getPackage().getName() + ":" + BasicServiceComponents.eesvcofV3.getClass().getPackage().getName());
      } catch (JAXBException e) {
          e.printStackTrace();
          return null;
      }
  
  }
  
  
  private static final JAXBContext context = initContext();
  
  @Bean
  public Marshaller marshaller() {
      Marshaller marshaller = null;
      try {
          marshaller = this.context.createMarshaller();
      } catch (JAXBException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      //any setters
      return marshaller;
  }
  
  @Bean
  public Unmarshaller unmarshaller() {
      Unmarshaller unmarshaller = null;
      try {
          unmarshaller = this.context.createUnmarshaller();
      } catch (JAXBException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      //any setters
      return unmarshaller;
  }
  </code></pre>
  
  <p>}</p>