title: Spring-boot-application with Hive-connection doesn't start embedded Tomcat
body: <p>I use Spring-Boot and want to connect it to Hive by spring-data-hadoop 2.3.0.M1-hdp23. The problem is that my application doesn't start if I add hive-jdbc to my pom.xml. The <strong>errorlog</strong> (partly) is:</p>
  
  <pre><code>     :: Spring Boot ::        (v1.2.4.RELEASE)
       2015-08-11 14:46:58.582  INFO 3528 --- [lication.main()] com.myApp.Application             : Starting Application on m with PID 3528 (/home/user/workspace/myApp/target/classes started by user in /home/user/workspace/myApp)
       2015-08-11 14:46:58.783  INFO 3528 --- [lication.main()] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5c01b2f: startup date [Tue Aug 11 14:46:58 CEST 2015]; root of context hierarchy
       2015-08-11 14:47:02.993  INFO 3528 --- [lication.main()] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
       2015-08-11 14:47:03.829  INFO 3528 --- [lication.main()] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$65dc2a7d] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
       2015-08-11 14:47:03.933  INFO 3528 --- [lication.main()] trationDelegate$BeanPostProcessorChecker : Bean 'transactionAttributeSource' of type [class org.springframework.transaction.annotation.AnnotationTransactionAttributeSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
       2015-08-11 14:47:03.991  INFO 3528 --- [lication.main()] trationDelegate$BeanPostProcessorChecker : Bean 'transactionInterceptor' of type [class org.springframework.transaction.interceptor.TransactionInterceptor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
       2015-08-11 14:47:04.015  INFO 3528 --- [lication.main()] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.config.internalTransactionAdvisor' of type [class org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
       2015-08-11 14:47:05.661  INFO 3528 --- [lication.main()] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
       2015-08-11 14:47:06.563  INFO 3528 --- [lication.main()] o.apache.catalina.core.StandardService   : Starting service Tomcat
       2015-08-11 14:47:06.566  INFO 3528 --- [lication.main()] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.0.23
       2015-08-11 14:47:07.336  INFO 3528 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
       2015-08-11 14:47:07.339  INFO 3528 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 8567 ms
       2015-08-11 14:47:10.608  INFO 3528 --- [ost-startStop-1] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@4a329af, org.springframework.security.web.context.SecurityContextPersistenceFilter@730530af, org.springframework.security.web.header.HeaderWriterFilter@777febdc, org.springframework.security.web.authentication.logout.LogoutFilter@29ef5cb1, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@27cac72b, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@17efd160, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@711567b0, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@f16564d, org.springframework.security.web.session.SessionManagementFilter@221bfb42, org.springframework.security.web.access.ExceptionTranslationFilter@4146c6af, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@710a1397]
       2015-08-11 14:47:10.802  INFO 3528 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'dispatcherServlet' to [/]
       2015-08-11 14:47:10.829 ERROR 3528 --- [cat-startStop-1] org.apache.catalina.core.ContainerBase   : A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
  at java.util.concurrent.FutureTask.report(FutureTask.java:122)
  at java.util.concurrent.FutureTask.get(FutureTask.java:192)
  at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:917)
  at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871)
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
  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.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
  ... 6 common frames omitted
       Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.addServlet(Ljava/lang/String;Ljavax/servlet/Servlet;)Ljavax/servlet/ServletRegistration$Dynamic;
  at org.springframework.boot.context.embedded.ServletRegistrationBean.onStartup(ServletRegistrationBean.java:189)
  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.selfInitialize(EmbeddedWebApplicationContext.java:222)
  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.access$000(EmbeddedWebApplicationContext.java:84)
  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext$1.onStartup(EmbeddedWebApplicationContext.java:206)
  at org.springframework.boot.context.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:54)
  at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5156)
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  ... 6 common frames omitted
  
       [...]
  
       org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474)
  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
  at com.myApp.Application.main(Application.java:16)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:483)
  at org.springframework.boot.maven.RunMojo$LaunchRunner.run(RunMojo.java:418)
  at java.lang.Thread.run(Thread.java:745)
       Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
  at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:98)
  at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.&lt;init&gt;(TomcatEmbeddedServletContainer.java:75)
  at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:378)
  at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:155)
  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:157)
  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
  ... 13 common frames omitted
       Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardServer[-1]]
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
  at org.apache.catalina.startup.Tomcat.start(Tomcat.java:337)
  at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:88)
  ... 18 common frames omitted
       Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Tomcat]]
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
  at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:769)
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  ... 20 common frames omitted
       Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat]]
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
  at org.apache.catalina.core.StandardService.startInternal(StandardService.java:439)
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  ... 22 common frames omitted
       Caused by: org.apache.catalina.LifecycleException: A child container failed during start
  at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:925)
  at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  ... 24 common frames omitted
  
       [...]
  
       [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.2.4.RELEASE:run (default-cli) on project myApp: An exception occured while running. null: InvocationTargetException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat: Failed to start component [StandardServer[-1]]: Failed to start component [StandardService[Tomcat]]: Failed to start component [StandardEngine[Tomcat]]: A child container failed during start
  </code></pre>
  
  <p>My <strong>pom.xml</strong> looks (partly) like:</p>
  
  <pre><code>        &lt;properties&gt;
              &lt;java.version&gt;1.8&lt;/java.version&gt;
          &lt;/properties&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;1.2.4.RELEASE&lt;/version&gt;
           &lt;/parent&gt;
  
           &lt;dependencies&gt;
               &lt;dependency&gt;
                   &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                   &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
               &lt;/dependency&gt;
               &lt;dependency&gt;
                   &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                   &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;/artifactId&gt;
               &lt;/dependency&gt;
               &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
               &lt;/dependency&gt;
               &lt;dependency&gt;
                  &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
                  &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;    
               &lt;/dependency&gt;
               &lt;dependency&gt;
                  &lt;groupId&gt;mysql&lt;/groupId&gt;
                  &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;   
               &lt;/dependency&gt;
               &lt;dependency&gt;
                  &lt;groupId&gt;org.apache.tomcat.embed&lt;/groupId&gt;
                  &lt;artifactId&gt;tomcat-embed-el&lt;/artifactId&gt;
               &lt;/dependency&gt;
  
              &lt;!-- Hive Dependencies --&gt;
                      &lt;dependency&gt;
                  &lt;groupId&gt;commons-dbcp&lt;/groupId&gt;
                  &lt;artifactId&gt;commons-dbcp&lt;/artifactId&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-data-hadoop-boot&lt;/artifactId&gt;
                  &lt;version&gt;2.3.0.M1-hdp23&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.apache.hive&lt;/groupId&gt;
                  &lt;artifactId&gt;hive-jdbc&lt;/artifactId&gt;
                  &lt;version&gt;1.2.1&lt;/version&gt;
                  &lt;exclusions&gt;
                      &lt;exclusion&gt;
                  &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
                  &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
              &lt;/exclusion&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;log4j&lt;/groupId&gt;
                  &lt;artifactId&gt;log4j&lt;/artifactId&gt;
              &lt;/exclusion&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;org.eclipse.jetty.aggregate&lt;/groupId&gt;
                  &lt;artifactId&gt;jetty-all&lt;/artifactId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
      &lt;/dependency&gt;
       &lt;dependency&gt;
          &lt;groupId&gt;org.apache.hadoop&lt;/groupId&gt;
          &lt;artifactId&gt;hadoop-core&lt;/artifactId&gt;
          &lt;version&gt;1.2.1&lt;/version&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                &lt;groupId&gt;tomcat&lt;/groupId&gt;
                &lt;artifactId&gt;jasper-runtime&lt;/artifactId&gt;
              &lt;/exclusion&gt;
              &lt;exclusion&gt;
                &lt;groupId&gt;tomcat&lt;/groupId&gt;
                &lt;artifactId&gt;jasper-compiler&lt;/artifactId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
      &lt;/dependency&gt;
          &lt;/dependencies&gt;
  </code></pre>
  
  <p>I have defined two data sources to use Hive and MySQL together, one as <strong><em>@Primary</em></strong> - but this is not a/the problem. My <strong>Application.java</strong> is:</p>
  
  <pre><code>    @EnableAutoConfiguration
      @PropertySource({"classpath:application.properties"})
      @ComponentScan("com.myApp")
      @SpringBootApplication
      public class Application {
          public static void main(String[] args) {
              SpringApplication.run(Application.class, args);
          }
      }
  </code></pre>
  
  <p>Interesting is: If I delete the <strong><em>hive-jdbc dependency</em></strong> out of my <strong>pom.xml</strong> the application starts and I can do everything else, like accessing my MySQL-connection and access all classes. Only if I want to access hive I got a <strong>java.lang.ClassNotFoundException: org.apache.hive.jdbc.HiveDriver</strong>. For sure, he can't find it because the dependency is missing, but it shows that this dependency makes trouble. I tried other versions, without success. If I remove the <strong><em>exclusion-tag</em></strong> I got an other error:</p>
  
  <pre><code>    org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is java.lang.NoSuchMethodError: org.eclipse.jetty.servlet.ServletMapping.setDefault(Z)V
  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474)
  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
  at com.myApp.Application.main(Application.java:16)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:483)
  at org.springframework.boot.maven.RunMojo$LaunchRunner.run(RunMojo.java:418)
  at java.lang.Thread.run(Thread.java:745)
      Caused by: java.lang.NoSuchMethodError: org.eclipse.jetty.servlet.ServletMapping.setDefault(Z)V
  at org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory.addDefaultServlet(JettyEmbeddedServletContainerFactory.java:289)
  at org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory.configureWebAppContext(JettyEmbeddedServletContainerFactory.java:236)
  at org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory.getEmbeddedServletContainer(JettyEmbeddedServletContainerFactory.java:122)
  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:157)
  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
  ... 13 common frames omitted
  </code></pre>
  
  <p>Hope anyone has an idea to solve this problem.</p>