title: SpringBoot - Unable to Start embedded TomCat
body: <p>I have a Spring Boot application. It runs on 2 servers. The servers have the same configuration.
  One one of this it works... on the other i'm getting this exception when starting it</p>
  
  <pre><code>2016-04-26 08:24:17.633 ERROR [localhost-startStop-1]: Error starting Tomcat context: org.springframework.beans.factory.BeanCreationException
  2016-04-26 08:24:17.903 ERROR [main]: Application startup failed
  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:532)
      at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)
      at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180)
      at it.besmart.parkserver.StartServer.main(StartServer.java:13)
      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:497)
      at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:54)
      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:99)
      at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.&lt;init&gt;(TomcatEmbeddedServletContainer.java:76)
      at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:457)
      at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:168)
      at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:160)
      at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
      ... 14 more
  </code></pre>
  
  <p>The stack trace continues for a lot of rows, mostly I get problems on auto wiring and injecting activities, with root cause</p>
  
  <pre><code>Invocation of init method failed; nested exception is org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
  </code></pre>
  
  <p>But my db.properties file is:</p>
  
  <pre><code>jdbc.driverClassName = com.mysql.jdbc.Driver
  jdbc.url = jdbc:mysql://192.168.3.240:3306/SMARTPARK?useSSL=false
  jdbc.username = parkuser
  jdbc.password = xxxxxxxxxxxxxxxx
  hibernate.dialect = org.hibernate.dialect.MySQLDialect
  hibernate.show_sql = false
  hibernate.format_sql = false
  </code></pre>
  
  <p>The DB is running (second server connects to it regularly..) and all privileges to users and hosts are correct</p>
  
  <p>This is my pom.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;it.besmart&lt;/groupId&gt;
      &lt;artifactId&gt;eparkserver&lt;/artifactId&gt;
      &lt;version&gt;1.0.0&lt;/version&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
  
      &lt;name&gt;eparkserver&lt;/name&gt;
      &lt;description&gt;ePark server&lt;/description&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.3.3.RELEASE&lt;/version&gt;
          &lt;relativePath /&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
          &lt;start-class&gt;it.besmart.parkserver.StartServer&lt;/start-class&gt;
          &lt;!-- 
          &lt;tomcat.version&gt;8.0.29&lt;/tomcat.version&gt;
           --&gt;
      &lt;/properties&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter&lt;/artifactId&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                      &lt;artifactId&gt;spring-boot-starter-logging&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-log4j&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.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-rest&lt;/artifactId&gt;
          &lt;/dependency&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;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.pi4j&lt;/groupId&gt;
              &lt;artifactId&gt;pi4j-core&lt;/artifactId&gt;
              &lt;version&gt;1.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-core&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;executable&gt;true&lt;/executable&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;server-copy&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;run&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;phase&gt;package&lt;/phase&gt;
                          &lt;configuration&gt;
                              &lt;target&gt;
                                  &lt;echo message="Push to server /home/pi/park/" /&gt;
                                  &lt;scp trust="yes" todir="pi:sofia2011@192.168.3.67:/home/pi/park/"&gt;
                                      &lt;fileset dir="${basedir}/target"&gt;
                                      &lt;/fileset&gt;
                                  &lt;/scp&gt;
                              &lt;/target&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
                  &lt;dependencies&gt;
                      &lt;dependency&gt;
                          &lt;groupId&gt;org.apache.ant&lt;/groupId&gt;
                          &lt;artifactId&gt;ant-jsch&lt;/artifactId&gt;
                          &lt;version&gt;1.9.6&lt;/version&gt;
                      &lt;/dependency&gt;
                  &lt;/dependencies&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>All my hibernate settings are in HibernateConfiguration.class (i migrated this app from Spring MVC to Spring Boot)</p>
  
  <pre><code>@Configuration
  @EnableTransactionManagement
  @ComponentScan({ "it.besmart" })
  @PropertySource(value = { "classpath:db.properties" })
  public class HibernateConfiguration {
  
  @Autowired
  private Environment environment;
  
  @Bean
  public LocalSessionFactoryBean sessionfactory(){
      LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
      sessionFactory.setDataSource(dataSource());
      sessionFactory.setPackagesToScan(new String[] {"it.besmart.models"});
      sessionFactory.setHibernateProperties(hibernateProperties());
      return sessionFactory;
  }
  
  @Bean
  public DataSource dataSource() {
      DriverManagerDataSource dataSource = new DriverManagerDataSource();
      dataSource.setDriverClassName(environment.getRequiredProperty("jdbc.driverClassName"));
      dataSource.setUrl(environment.getRequiredProperty("jdbc.url"));
      dataSource.setUsername(environment.getRequiredProperty("jdbc.username"));
      dataSource.setPassword(environment.getRequiredProperty("jdbc.password"));
      return dataSource;
  }
  
  private Properties hibernateProperties() {
      Properties properties = new Properties();
      properties.put("hibernate.dialect", environment.getRequiredProperty("hibernate.dialect"));
      properties.put("hibernate.show_sql", environment.getRequiredProperty("hibernate.show_sql"));
      properties.put("hibernate.format_sql", environment.getRequiredProperty("hibernate.format_sql"));
      return properties;        
  }
  
  @Bean
  @Autowired
  public HibernateTransactionManager transactionManager(SessionFactory s) {
     HibernateTransactionManager txManager = new HibernateTransactionManager();
     txManager.setSessionFactory(s);
     return txManager;
  }
  }
  </code></pre>
  
  <p>I don't know what is happening</p>